lazy-load the sort order to prevent hitting the DB in rake tasks

resolves #2342