updating sorting algorithm