I have a list in swi-prolog like this:
[(5,4), (1,4), (3,12), (4,2), (5,4)]
I need to have the list organized by the second element of each "tuple", removing any repeated elements, so this list would look like this:
[(4,2), (1,4), (5,4), (3,12)]
Using the predicate sort/2, it does everything I want, except it organizes according the first element of each tuple, which I don't want.
How can I do it?