note 64034 modified in function.usort by danbrown
| From: | danbrown@php.net | Date: | Sun, 23 Jan 2011 16:27:17 +0000 |
| Subject: | note 64034 modified in function.usort by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176070@lists.php.net to get a copy of this message | ||
For using usort inside a method in an object, where the callback sort method is in the same object,
this works:
<?php usort($arr_to_sort, array($this, "sort_terms_by_criteria")); ?>
If you wish to keep elements in their original or reverse order if they are the same length, just
don't return zero for items that compare the same. Return a 1 or -1, as appropriate.
--was--
For using usort inside a method in an object, where the callback sort method is in the same object,
this works:
usort($arr_to_sort, array($this, "sort_terms_by_criteria"));
If you wish to keep elements in their original or reverse order if they are the same length, just
don't return zero for items that compare the same. Return a 1 or -1, as appropriate.
http://php.net/manual/en/function.usort.php