finished the sorting