Reputation: 28648
I have a list like
L = [0-4, 0-3, 3-5, 1-2]
and I would like to sort the list by key and value so the result would be
L = [0-3, 0-4, 1-2, 3-5]
I found keysort but it sorts only by key. I can write the sort by myself but I need an efficient solution.
Upvotes: 0
Views: 486
Reputation: 60014
call sort/2 (or msort/2 if you want keep duplicates)
?- sort([0-4, 0-3, 3-5, 1-2], S).
S = [0-3, 0-4, 1-2, 3-5].
Upvotes: 1