Sorting of tuples