PHP Class Sulu\Component\Util\SortUtils

Show file Open project: sulu/sulu Class Usage Examples

Public Methods

Method Description
multisort ( array $values, $paths, string $direction = 'ASC' ) : array Sort the given array of arrays/objects using paths.

Private Methods

Method Description
__construct ( ) Cannot instantiate this class.

Method Details

multisort() public static method

e.g. $data = array( array('foobar' => 'b'), array('foobar' => 'a'), ); SortUtils::multisort($data, '[foobar]', 'asc'); echo $data[0]; // "a" You can also use method names: SortUtils::multisort($data, 'getFoobar', 'asc'); Or sort on multidimensional arrays: SortUtils::multisort($data, 'foobar.bar.getFoobar', 'asc'); And you can sort on multiple paths: SortUtils::multisort($data, array('foo', 'bar'), 'asc'); The path is any path accepted by the property access component:
public static multisort ( array $values, $paths, string $direction = 'ASC' ) : array
$values array
$direction string Direction to sort in (either ASC or DESC)
return array