SortedBy |
Syntax |
SortedBy(L: LIST, F: FUNCTION): LIST |
Description |
Example |
/**/ Define ByLength(S, T) -- define the sorting function /**/ Return len(S) > len(T); /**/ EndDefine; /**/ M := ["bird","mouse","cat"]; /**/ SortedBy(M, ByLength); ["mouse", "bird", "cat"] /**/ M; -- M is not changed ["bird", "mouse", "cat"] /**/ sorted(M); -- the function "Sort" sorts using the default ordering: -- in this case, alphabetical order. ["cat", "bird", "mouse"] /**/ SortBy(ref M, ByLength); -- sort M in place, changing M /**/ M; ["mouse", "bird", "cat"] |
See Also |