<p>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).</p>

It shouldn't be too hard to write your own sort function (adapted from a common example):
```
```
qsort([]) -> [];
qsort([Pivot|Tail]) ->
    {PivotFirst, PivotSecond} = Pivot,
    qsort([{FirstElement, SecondElement} || {FirstElement,SecondElement} <- Tail, SecondElement < PivotSecond])
        ++ [Pivot] ++
        qsort([{FirstElement, SecondElement} || {FirstElement,SecondElement} <- Tail, SecondElement >= PivotSecond]).
```
```