Implement sort_by

:construction: DO NOT MERGE :construction_worker: 

/cc @Haacked