worked on the sorting algorithm