SamCritch Posted June 7, 2010 Share Posted June 7, 2010 Hi, I want to sort a three-dimensional associative array containing some people's ages by age (so the sort would be numeric, rising). I've managed to work out how to use uasort() to do this with a two-dimensional associative array, but I can't seem to do this with a three-dimensional associative array. Here's the array I have: $demoarray = Array ( 'males' => Array ( 'george1' => Array ( 'name' => George, 'age' => 32 ), ), 'females' => Array ( 'george1' => Array ( 'name' => Georgia, 'age' => 16 ), 'george2' => Array ( 'name' => Georgette, 'age' => 54 ), 'george3' => Array ( 'name' => Georgina, 'age' => 27 ), ), ) ; How can I sort this so it comes back in ascending order of age across both males and females? Any ideas? Or am I misunderstanding the function? Thanks in advance, Sam Link to comment https://forums.phpfreaks.com/topic/204101-sorting-three-dimensional-associative-arrays/ Share on other sites More sharing options...
ignace Posted June 7, 2010 Share Posted June 7, 2010 Why not pass: uasort($demoarray['males']);? Link to comment https://forums.phpfreaks.com/topic/204101-sorting-three-dimensional-associative-arrays/#findComment-1069056 Share on other sites More sharing options...
GoneNowBye Posted June 7, 2010 Share Posted June 7, 2010 php info on the UASORT it works well, bassed on what you return- one may make there own comparassions. Link to comment https://forums.phpfreaks.com/topic/204101-sorting-three-dimensional-associative-arrays/#findComment-1069105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.