I have the following array
$infoArray = Array
(
[Shockwafe Ultra 9.2] => Array
(
[0] => 8
[1] => 45 Hz - 18.000 Hz
[2] => 9.2
[3] => 1
[4] => 1
[5] => 1
[6] =>
[7] =>
[8] => B+
[9] => B+
[10] => A
[11] => B
)
[Bose 5.1 SoundTouch 300] => Array
(
[0] => 9
[1] => 45 Hz - 20.000 Hz
[2] => 5.1
[3] => 1
[4] => 1
[5] => 1
[6] => 1
[7] => 1
[8] => A
[9] => A
[10] => A+
[11] => A+
)
[Sonos 5.1 System] => Array
(
[0] => 10
[1] => 31.5 Hz - 20.000 Hz
[2] => 5.1
[3] => 1
[4] => 1
[5] => 1
[6] => 1
[7] => 1
[8] => A+
[9] => A+
[10] => A+
[11] => A+
)
)
I am trying to sort it with the use of PHP. I want to sort by the [0] value in each array member. So the order should be, Sonos first, Bose second, Shockwafe third.
My PHP code looks as following:
function sortByOrder($a, $b) {
return $a[0] - $b[0]; }
uasort($infoArray, 'sortByOrder');
I've tried this on wamp, where it succesfully arranges the order like i'd want. However, online in my Wordpress installation, this does NOT work. It simply does not re-arrange the array. It should be noted, that I am working inside functions.php within a shortcode. I tried moving the sortByOrder() function outside of the shortcode area, with no success.
Any ideas what goes wrong?