|
posted 06/10/2008 by James
If you're using the function usort inside a cakephp controller and are receiving errors like "Warning: usort() [function.usort]: Invalid comparison function in..." you may be referencing your sorting function incorrectly.
Try calling usort this way...
class ItemsController extends AppController { // if reusable, then you should consider putting this function in app_controller.php function item_sorter($a,$b) { //... comparison logic } usort($unsorted_list, array('ItemsController','item_sorter')); //$unsorted_list is now sorted } } COMMENTS (displaying 0 comments) POST (leave a comment) |
POPULAR BLOG TAGS
hobnox
debuggeddesigns
gmail
class
general
php5tube
rot13
cakephp
code
snowboard
usort
privacy
ableton
drum machines
as
science
skateboard
trice
mailto
spam
routes
security
color
magazine
sports
geek
quicksilver
encryption
open source
release
google
regular expressions
1984
orwell
charlie
mit
germans
defcon
launch
email
bakery
mbta
flash
brain
boston
published
php
whoami
captcha
youtube
|