L | : | list ( array) |
orderproc | : | procedure |
Returns: list (array)
Synopsis: The sort function can order a list (array) containing any type of elements as long as these elements are comparable ie. the operators <, >, <>, =, <=, >= are applicable and well-defined. When only supplied a list, sort places the elements in ascending order and returns a copy of the L.
The optional second argument must specify an ordering procedure.
Examples:
> a := [521, -923, 1293, 521, -3342]; > sort(a); # ascending order. > sort(a, a -> -a); # descending order. > neg := proc(a) > return(abs(a)); > end; > sort(a, neg); # ascending absolute value order. > b := [['a', 'f'], ['b', 'e'], ['c', 'd']]; > sort(b, b->b[2]); # sort on second element of list