Hi, I was trying to sort a multi dimensional array .. e.g $todo_cats[0]["TodoCat"]["name"] = "Basic Todo"; $todo_cats[0]["TodoTask"][0]["id"] = 1; $todo_cats[0]["TodoTask"][0]["name"] = "Select a date"; $todo_cats[0]["TodoTask"][0]["position"] = 2; $todo_cats[0]["TodoTask"][1]["id"] = 2; $todo_cats[0]["TodoTask"][1]["name"] = "Determine your budget"; $todo_cats[0]["TodoTask"][1]["position"] = 1; i tried sorting using the code below .. which did not work .. foreach($todo_cats as $key =>$cat){ foreach($cat["TodoTask"] as $key1 => $row){ $position[$key1] = $row['position']; } array_multisort($position, SORT_ASC, $cat["TodoTask"]); } Any clue how do i sort it ... ??
If you don't mind creating a new array or won't affect your scripting you could sort the array and it's sub arrays individually while passing them into a new array. Do I make sense.
jestep is spot on, usort is the way to go. Here is a useful link for you. http://www.informit.com/articles/article.aspx?p=31840&seqNum=6