public static function orderBy(array $tokens, array $content) {
        if (empty($tokens['ORDER'])) return $content;

        $sortingRules = array_map(function($token) use ($content) {
            return [
                end($token['no_quotes']['parts']),
                $token['direction']
            ];
        }, $tokens['ORDER']);

        $reducedSortingRules = array_reduce($sortingRules, 'array_merge', []);
        $sortArgs            = array_map(function($value) use ($content) {
            if ($value === 'ASC')  return SORT_ASC;
            if ($value === 'DESC') return SORT_DESC;

            $contents = [];
            foreach ($content as $c) array_push($contents, $c[$value]);
            return $contents;
        }, $reducedSortingRules);

        $sortArgs[] = &$content;
        call_user_func_array('array_multisort', $sortArgs);

        return end($sortArgs);
    }
public static function orderBy(array $tokens, array $content) {
        if (empty($tokens['ORDER'])) return $content;

        $sortingRules = array_map(function($token) use ($content) {
            return [
                end($token['no_quotes']['parts']),
                $token['direction']
            ];
        }, $tokens['ORDER']);

        $reducedSortingRules = array_reduce($sortingRules, 'array_merge', []);
        $sortArgs            = array_map(function($value) use ($content) {
            if ($value === 'ASC')  return SORT_ASC;
            if ($value === 'DESC') return SORT_DESC;

            $contents = [];
            foreach ($content as $c) array_push($contents, $c[$value]);
            return $contents;
        }, $reducedSortingRules);

        $sortArgs[] = &$content;
        call_user_func_array('array_multisort', $sortArgs);

        return end($sortArgs);
    }
public static function orderBy ( array $ tokens , array $ content ) { if ( empty ( $ tokens [ 'ORDER' ] ) ) return $ content ; $ sortingRules = array_map ( function ( $ token ) use ( $ content ) { return [ end ( $ token [ 'no_quotes' ] [ 'parts' ] ) , $ token [ 'direction' ] ] ; } , $ tokens [ 'ORDER' ] ) ; $ reducedSortingRules = array_reduce ( $ sortingRules , 'array_merge' , [ ] ) ; $ sortArgs = array_map ( function ( $ value ) use ( $ content ) { if ( $ value === 'ASC' ) return SORT_ASC ; if ( $ value === 'DESC' ) return SORT_DESC ; $ contents = [ ] ; foreach ( $ content as $ c ) array_push ( $ contents , $ c [ $ value ] ) ; return $ contents ; } , $ reducedSortingRules ) ; $ sortArgs [ ] = & $ content ; call_user_func_array ( 'array_multisort' , $ sortArgs ) ; return end ( $ sortArgs ) ; }
Orders the content with the given order by criteria

@param  array $tokens
@param  array $content
@return array
Orders the content with the given order by criteria