Only show default ordering option when relevant

Closes #5893
Move orderby logic out of template file

cc @jameskoster @claudiosmweb