public function sort($sorts)
    {
        usort($this->rows, 
            function ($a, $b) use ($sorts) {
                $cmp = 0;
                foreach ($sorts as $sort => $direction) {
                    if (is_string($direction)) {
                        $cmp = is_numeric($a[$sort]) && is_numeric($b[$sort]) ? 
                            $a[$sort] - $b[$sort] : strcmp($a[$sort], $b[$sort]);
                        $cmp = $direction === 'asc' ? $cmp : - $cmp;
                    } else if (is_callable($direction)) {
                        $cmp = $direction($a[$sort], $b[$sort]);
                    }
                    if ($cmp !== 0) {
                        break;
                    }
                }
                return $cmp;
            }
        );
        return $this;
    }
public function sort($sorts)
    {
        usort($this->rows, 
            function ($a, $b) use ($sorts) {
                $cmp = 0;
                foreach ($sorts as $sort => $direction) {
                    if (is_string($direction)) {
                        $cmp = is_numeric($a[$sort]) && is_numeric($b[$sort]) ? 
                            $a[$sort] - $b[$sort] : strcmp($a[$sort], $b[$sort]);
                        $cmp = $direction === 'asc' ? $cmp : - $cmp;
                    } else if (is_callable($direction)) {
                        $cmp = $direction($a[$sort], $b[$sort]);
                    }
                    if ($cmp !== 0) {
                        break;
                    }
                }
                return $cmp;
            }
        );
        return $this;
    }
public function sort ( $ sorts ) { usort ( $ this -> rows , function ( $ a , $ b ) use ( $ sorts ) { $ cmp = 0 ; foreach ( $ sorts as $ sort => $ direction ) { if ( is_string ( $ direction ) ) { $ cmp = is_numeric ( $ a [ $ sort ] ) && is_numeric ( $ b [ $ sort ] ) ? $ a [ $ sort ] - $ b [ $ sort ] : strcmp ( $ a [ $ sort ] , $ b [ $ sort ] ) ; $ cmp = $ direction === 'asc' ? $ cmp : - $ cmp ; } else if ( is_callable ( $ direction ) ) { $ cmp = $ direction ( $ a [ $ sort ] , $ b [ $ sort ] ) ; } if ( $ cmp !== 0 ) { break ; } } return $ cmp ; } ) ; return $ this ; }
Sort the rows of data

Examples:

$store->sort(array("age"=>"desc"));

@param array $sorts Condition of sorting

@return DataStore This datastore
Sort the rows of data