You should use the array#sort() method. More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
Example:
<<set $myArray to [5, 8, 1, 6, 3]>> <<= $myArray.join(' ')>> <<set $myArray to $myArray.sort()>> <<= $myArray.join(' ')>>
You can pass a sorting function to the sort() method if you want it to sort in some specific way, but we'd need more info to provide any examples.
There's no good reason to use a <<for>> macro for this.