changes sort to stablesort