Page MenuHomePhorge

function msort($list, $method)
Arcanist Technical Documentation ()

Sort a list of objects by the return value of some method. In PHP, this is often vastly more efficient than usort() and similar.

// Sort a list of Duck objects by name.
$sorted = msort($ducks, 'getName');

It is usually significantly more efficient to define an ordering method on objects and call msort() than to write a comparator. It is often more convenient, as well.

NOTE: This method does not take the list by reference; it returns a new list.
Parameters
list$listList of objects to sort by some property.
string$methodName of a method to call on each object; the return values will be used to sort the list.
Return
listObjects ordered by the return values of the method calls.