How to rearrange views PHP sorting criteria? Usually, it works fine when I rearrange two or more sorting criteria within a Views (simple drag and drop) but in my case (Content fields grouped by taxonomy terms), one of the sorting criteria is a Global:PHP (based on a PHP field) and it seems like it is always treated first whatever level I choose? And of course, I need it to be treated secondly. 

EDIT1 : Here is the problem in details

I have a list of nodes with pagination (1-15, 16-28, etc.). I also have a taxonomy field to group the nodes (categories). I need to sort the nodes by taxonomy terms (according to the weight) and secondly by first page. I get the first page using a PHP field to extract the data from the pagination. If I use the pagination field directly, the sorting is wrong (page 100 will appear before page 11, "alphabetical order").

Finally, I need :

Term 1

Node 1 pages 1-15

Node 4 pages 78-100

Node 12 pages 167-184

Term 2

Node 2 pages 16-45

Node 10 pages 110-125

Term 3

etc.

Any idea?

Thanks.

Related posts : 

Cant get desired results for multiple sort criteria in a view

Sort criteria is ignored in Views

Views: custom field for sort criteria

EDIT2 :
As suggested by Smalution, a custom module could help. I am thus working on the little code needed to sort my View using a custom PHP field. I am using hook_views_query_alter and add_orderby but I can not find the right way to write it since the custom PHP field is not stored in a table like any other standard Drupal fields (the PHP field is computed when the View is calculated). Could anyone help me to complete the code given by Smalution? Thanks for any tip. Tell me if more details are needed.
You can go for hook_views_query_alter.


  Alter the query before executing the query.


function module_name_views_query_alter(&amp;$view, &amp;$query) {
  if ($view-&gt;name == 'Viewname') {
    //dpm($view-&gt;query-&gt;orderby[0]);
   // put your modified sorting criteria
  }
}