LdapTools\Query\LdapResultSorter::sort PHP Метод

sort() публичный Метод

Reorganize the array to the desired orderBy methods passed to the class.
public sort ( array | LdapObjectCollection $results ) : array | LdapObjectCollection
$results array | LdapTools\Object\LdapObjectCollection The unsorted result set.
Результат array | LdapTools\Object\LdapObjectCollection The sorted result set.
    public function sort($results)
    {
        $isCollection = $results instanceof LdapObjectCollection;
        $results = $isCollection ? $results->toArray() : $results;
        // We need to track the index when sorting to ensure a stable sort. This is essentially how PHP 7+ handles
        // things, but not PHP 5.6. I think this would be the expected order, especially for tests/specs...
        foreach ($results as $index => &$item) {
            $item = [$index + 1, $item];
        }
        usort($results, [$this, 'resultSortCallback']);
        // Sort done, so remove the index tracking from the results...
        foreach ($results as &$item) {
            $item = $item[1];
        }
        return $isCollection ? new LdapObjectCollection(...$results) : $results;
    }