srt()
What does srt() do?
srt() sorts an array or string using the python sorted() function, from smallest to largest
from ArrayExpressions import arrex
lst = [1, 8, 6, 4, 3]
output = arrex.evaluate(lst, "srt(x)")
print(output) # [1, 3, 4, 6, 8]
Other Important Information:
Input | Any array or string |
---|---|
Does it create a new scope? | No |
Output | A sorted array |
K | None |
I | Same index |
Example | srt("acbdfE") |
Example Explanation | This sorts the string to Eabcdef. E is in front because strings are compared by ASCII value, not alphabetically. |