How to order views programmatically. You might need to do this on special occasions. This hook initializes before query is built so it goes for all data, not just current page.
Source code viewer
function hook_views_query_alter(&$view, &$query) { if('view_machine_name' == $view->name) { #print the structure #order by what ever you need } }Programming Language: PHP