Generalized sorting.