Subject: [SWIPL] keysort

From: Cecilia Wong <[email-masked]>
Date: Mon, 19 Feb 2001 14:28:08 +0800

Hi,

    I intend to use the "keysort" predicate to sort a list according to one of the arguments in the list.
For example, I have the list, [[a, b, 2], [a, c, 3], [a, b, 1], [b, a, 5], [d, c, 4], [f, r, 6]]. And I want the 
resultant list to be sorted like this, [[a, b, 1], [a, b, 2], [a, c, 3], [d, c, 4], [b, a, 5], [f, r, 6]], according 
 to the last argument of the lists in the list. Can this predicate help?

    I am really confused about the syntax of using keysort. As the manual stated, "List is a list of 
Key-Value pairs (e.g. terms of the functor `-' with arity 2)".
Can anyone give an example on how to use this predicate? 

    Thank you very much!

Cecilia