array_multisort accepts column arrays but here you try to sort row based
arrays.
try this:
<?
class ArrayUtility
{
/* Sorts an array by a member */
static private $sortMember;
static function sortByMember(&$array, $member)
{
self::$sortMember = $member;
usort($array, array('ArrayUtility', 'compareMember'));
}
static function compareMember($a, $b)
{
return $a[self::$sortMember] > $b[self::$sortMember];
}
}
ArrayUtility::sortByMember($array, 'quantity');
?>
Am 25.04.2007, 12:36 Uhr, schrieb Frank Arensmeier
<frank.arensmeier@xxxxxxxxxxxxxxxxx>:
Jon, I would suggest that you should have a look at the function
"array_multisort". See the manual for details on what this function is
capable of.
//frank
25 apr 2007 kl. 01.58 skrev Jon Bennett:
hi,
I have the following array, which I need to sort by quantity...
Array
(
[2408] => Array
(
[name] => Havaianas Top Pink Crystal
[size] => 5 (37/38)
[quantity] => 4
)
[3388] => Array
(
[name] => Havaianas Brazil Silver
[size] => 6/7 (39/40)
[quantity] => 6
)
[2666] => Array
(
[name] => Havaianas Brasil Black
[size] => 8/9 (41/42)
[quantity] => 1
)
[3210] => Array
(
[name] => Havaianas Margaridas Yellow
[size] => 5 (37/38)
[quantity] => 1
)
[2552] => Array
(
[name] => Havaianas Flash White
[size] => 5 (37/38)
[quantity] => 1
)
)
I need to keep the indexes if poss.
Many thanks,
jon
--
jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett
--PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php