feat(orderBy): speed optimization

Closes #4177.