So Ive got a pretty big array of data and need to sort them by two criteria.
There is variable $data['important']
and $data['basic']
.
They are simple numbers and I am using uasort to sort
$data
firstly by important and then by basic.
So
Important | Basic
10 | 8
9 | 9
9 | 7
7 | 9
The usort function is a simple
public function sort_by_important($a, $b) {
if ($a[important] > $b[important]) {
return -1;
}
elseif ($b[important] > $a[important]) {
return 1;
}
else {
return 0;
}
}
How can I re-sort the array to the second variable and keep the Important ordering?
Thanks everyone.
EDIT
How about adding a third sorting option after this even? So Important > Basic > Less