After searching the internet for something trivial like the sorting a multidimensional array I found the following solution.
function sort_multi_array(&$array, $key)
{
foreach($array as &$value) {
$value['__________'] = $value[$key];
}
/* Note, if your functions are inside of a class, use:
usort($array, array("My_Class", 'sort_by_dummy_key'));
*/
usort($array, 'sort_by_dummy_key');
foreach($array as &$value) { // removes the dummy key from your array
unset($value['__________']);
}
return $array;
}
function sort_by_dummy_key($a, $b)
{
if($a['__________'] == $b['__________']) return 0;
if($a['__________'] < $b['__________']) return -1;
return 1;
}
Looks a little bit weird but it gives the simple ability to just pass in the array and the key you want your array sorted by.
So for an array like this:
$dimension_array = array( array("source"=>"google.com/images", "dimensions"=>156000), array("source"=>"bing.com/images", "dimensions"=>12000), array("source"=>"flickr.com/images", "dimensions"=>160000));
You would make one simple call and if you want the result in reverse order you simple reverse the array and you’re done.
$sorted = sort_multi_array($dimension_array, "dimensions"); // If you want your sorted array in reverse order $final_image_array = array_reverse( $sorted );
As I mentioned the “sort_multi_array” looks a little weird but it is quite simple. What it does is, it takes your passed $key parameter and assigns it to a value with a dummy key. Now we can just use the easy “usort” function to compare the “keys” and finally we remove the “dummy_key. Done.
I found this code here.
If you have questions leave me a comment.

Thank you..really informative!!
Hmm is anyone else experiencing problems with the images on this blog loading? I’m trying to find out if its a problem on my end or if it’s the blog. Any feed-back would be greatly appreciated.
Hi, do you have a flash plugin installed?
It’s working fine for me using Mac OS X from New Zealand.