Entity filed query for sorting by title and weight both?
This is more of a straight PHP question than a Drupal question, but it looks as if you have a bug in your value comparing function. It should return 1 if you want $a to sort greater than $b, it should return -1 for $b to sort greater than $a, and it should return 0 if the items should sort equally. But your function will only ever return 0 or 1. Try replacing your last return statement with return ($a_weight &gt; $b_weight) ? 1 : -1;