This is List L:
['25', '2', '15', '4', '81', '43']
This is the output when I use the command sort(L)
['15', '2', '25', '4', '43', '81']
This is what I want as output:
['2', '4', '15', '25', '43', '81']
Is there a command to sort numbers in a list as %sort n does in commandline?
This is explained in the documentation. You need to define a function to do the comparison between list entries. The function should return 0 if its arguments are equal, 1 if the the first argument is larger than the second, and -1 if the second argument is larger than the first.
Then you can call sort() using your new function as the second argument. Hence:
will echo
as expected.