src/Base/Statements.php
public function orderBy(string $column, string $order = 'ASC'): CollectionInterface
    {
        return $this->sort(
            function ($a, $b) use ($column, $order) {
                if (strtoupper($order) == 'ASC') {
                    return $a[$column] <=> $b[$column];
                } elseif (strtoupper($order) == 'DESC') {
                    return $b[$column] <=> $a[$column];
                }
                // Must throw exception if item column does not exists
            }
        );
    }
public function orderBy(string $column, string $order = 'ASC'): CollectionInterface
    {
        return $this->sort(
            function ($a, $b) use ($column, $order) {
                if (strtoupper($order) == 'ASC') {
                    return $a[$column] <=> $b[$column];
                } elseif (strtoupper($order) == 'DESC') {
                    return $b[$column] <=> $a[$column];
                }
                // Must throw exception if item column does not exists
            }
        );
    }
public function orderBy ( string $ column , string $ order = 'ASC' ) : CollectionInterface { return $ this -> sort ( function ( $ a , $ b ) use ( $ column , $ order ) { if ( strtoupper ( $ order ) == 'ASC' ) { return $ a [ $ column ] <=> $ b [ $ column ] ; } elseif ( strtoupper ( $ order ) == 'DESC' ) { return $ b [ $ column ] <=> $ a [ $ column ] ; } // Must throw exception if item column does not exists } ) ; }
Returns a new Collection containing the items ordered by the especified column.

@todo MUST throw exception if the column does not exists

@param string $column The column to order by.
@param string $order  The order to sort the items.

@return Collection A new collection instance.
Returns a new Collection containing the items ordered by the especified column .