Sorts the elements of the list List1 into ascending standard order (see ref-lte-cte-sot with respect to the key of the pair structure.
The list List1 must consist of terms of the form Key-Value. Multiple occurrences of any term are not removed.
(The time taken to do this is at worst order (N log N) where N is the length of the list.)
Note that the elements of List1 are sorted only according to the value of Key, not according to the value of Value.
keysort is stable in the sense that the relative position of
elements with the same key maintained.
| ?- keysort([3-a,1-b,2-c,1-a,1-b], X). X = [1-b,1-a,1-b,2-c,3-a]
|?- keysort([2-1, 1-2], [1-2, 2-1]). yes