Clarify sorting logic