Fixed sorting algorithm to correctly use "tuples" or "pairs".
It still does NOT sort a list of one tuple correctly.