Sorting and dividing