


Sort a list of string-pairs by first element:
eval: sort (fn ((a,_),(b,_)) = a > b) [ ("abc","xyz"), ("xyz","abc"), ("jkl","mno") ];
[("abc", "xyz"), ("jkl", "mno"), ("xyz", "abc")]
(The above will work no matter what the type of the the second element.)
Sort a list of string-pairs by second element:
eval: sort (fn ((_,a),(_,b)) = a > b) [ ("abc","xyz"), ("xyz","abc"), ("jkl","mno") ];
[("xyz", "abc"), ("jkl", "mno"), ("abc", "xyz")]
(The above will work no matter what type the type of the first element.)
Sort a list of records by some field:
eval: sort (fn (a,b) = a.key > b.key) [ { key => "abc", value => "xyz" }, { key => "xyz", value => "abc" }, { key => "jkl", value => "mno" } ];
[{ key="abc", value="xyz" },
{ key="jkl", value="mno" },
{ key="xyz", value="abc" }]
In a program (vs a script) you will want to replace sort by list_mergesort::sort.


