+ $cmp_order = array('weight', 'id', 'title', 'name');
+ foreach ($cmp_order as $attribute) {
+ if (isset($a[$attribute]) && isset($b[$attribute])) {
+ if ($a[$attribute] < $b[$attribute]) {
+ return -1;
+ } elseif ($a[$attribute] > $b[$attribute]) {
+ return 1;
+ } // else: $a and $b are equal wrt to this attribute, try next...
+ }
+ }
+ // if we get here, $a and $b es equal for all we know
+ // however, as I understand we don't want equality here:
+ return -1;