working on sorting algorithm