Update sorting algorithm