sort->stable_sort for all greedy sorting