fix(orderBy): sort by identity if no predicate is given

This implementation handles all the various corner cases more consistently.

Closes #5847
Closes #4579