Fix inconsistent sort behavior.