I need to sort tuples according to the second element of each tuple but apparently usort/1 only works with the first element. So I have to swap the elements, usort them and swap back.Is there an easier way?Also is there a way to sort in descending order (I know sorting and reversing can be done, but just want to know).
Share
Have you tried keysort/2 function (or its counterpart ukeysort/2)?
If you don’t sort very big lists this is probably the most readable solution you can get.