stable sorting algorithm