Fixed sorting algorithm