Moved sorting to view.html.php as well