Revert "move sorting to UI layer"

This reverts commit 168d98fea491ac9be8dbd03e355ef12a6cbc067d.