Improved sorting of pagination.