Revert "Do the sorting inline"

This reverts commit a5f1b557e98d80f51b8d5323092c26aaae579129.