In reply to dave_59:
Hi Dave,
Thanks for your suggestion, do you know where I can find those build in functions such as sort()
After I take a look on other topics in the forum, below is my implementation, it seems to work.
foreach (ts[i])
foreach (ts[j])
if (i<j) ts[i] <ts[j];