How to constrain a dynamic array with the incremental pattern for each elements

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];