Correctly encode sort as a list of tuples.