I'm trying to figure out how to sort an array, that has sub arrays which each have an X & Y coordinate. I need to sort the largest size first to the smallest, example:
$sizes = array(
'a' => array(
'x' => 10,
'y' => 140,
),
'b' => array(
'x' => 20,
'y' => 24,
),
'c' => array(
'x' => 20,
'y' => 40,
),
'd' => array(
'x' => 50,
'y' => 50,
),
'e' => array(
'x' => 10,
'y' => 9,
),
);
Should resort naturally like so:
$sizes = array(
'e' => array(
'x' => 10,
'y' => 9,
),
'b' => array(
'x' => 20,
'y' => 24,
),
'c' => array(
'x' => 20,
'y' => 40,
),
'd' => array(
'x' => 50,
'y' => 50,
),
'a' => array(
'x' => 10,
'y' => 140,
),
);
I've sorted by value before using asort, however I'm not sure how to sort and maintain index association on a multidimensional array like this. Any help would be great!