PhpDig.net

PhpDig.net (http://www.phpdig.net/forum/index.php)
-   Coding & Tutorials (http://www.phpdig.net/forum/forumdisplay.php?f=31)
-   -   Sorting within Class (http://www.phpdig.net/forum/showthread.php?t=954)

griffinmt 05-23-2004 10:43 AM

Sorting within Class
 
Having trouble using usort within a class.
Example:
class User {
var $fn;
var $ln;
var $id;
function User() { ...}
...
}
class Users {
var $list = array();
function Users() {...}
function addUser($U) {array_push($this->list,$U);}
...
}

above are two classes, the second (Users) is an array of User class objects. From within Users, I would like to sort the array (using usort) such that the elements are in sequence by User->ln

Cannot get it to invoke the comparison function and the result is a somewhat r****me sequence. :bang:

What is the most efficient way to call the usort and code the associated coomparision function?

Thanks


All times are GMT -8. The time now is 10:43 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.