P-Sorting