Add stable_sort_each function.