PDA

View Full Version : To sort a multidimensional array


akanevsky
05-28-2005, 06:39 PM
Say, I have this:

$array = array(
array('name' => 'b', 'type' => '1'),
array('name' => 'f', 'type' => '0'),
array('name' => 'c', 'type' => '1')
array('name' => 'h', 'type' => '0')
);

I want to sort the arrays first by type, then by name.
So that it'd be:

$array = array(
array('name' => 'f', 'type' => '0'),
array('name' => 'h', 'type' => '0')
array('name' => 'b', 'type' => '1'),
array('name' => 'c', 'type' => '1')
);

How can I do that?

EDIT: OMG, Sometimes I can be really dumb. Why don't I define the order when querying from the database... Duh.