simplified sort logic