note 23101 deleted from function.uksort by didou
| From: | didou@php.net | Date: | Tue, 29 Jul 2003 11:55:18 +0000 |
| Subject: | note 23101 deleted from function.uksort by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-52906@lists.php.net to get a copy of this message | ||
Note Submitter: baatsaamNO_SPAM@hotmail.com
----
If you have an array such as:
$items = array(
'ABC' = array(
'price' = 123,
'desc' = 'asdf'
)
'DEF' = array(
'price' = 321,
'desc' = 'jkl'
)
);
...and want to sort by description, one way of doing it is:
-----------------
function sortItems($a, $b) {
global $items;
return strcasecmp($items[$a]['desc'], $items[$a]['desc']);
}
uksort($items, "sortItems");
-----------------
If there's a better way, please let me know. :)