src/Arrays.php
public static function sortByCol(
        array &$array, $column, $sort = SORT_STRING, $direction = SORT_ASC
    )
    {
        if (!sizeof($array)) {
            return;
        }

        $index = [];
        $i = 0;
        foreach ($array as $key => $row) {
            if (is_array($row)) {
                $index['pos'][$i]  = $key;
                $index['name'][$i] = $row[$column];
                ++$i;
            }
        }
        array_multisort($index['name'], $sort, $direction, $index['pos']);
        $result = array();
        for ($j = 0; $j < $i; ++$j) {
            $result[$index['pos'][$j]] = $array[$index['pos'][$j]];
        }
        $array = $result;
    }
public static function sortByCol(
        array &$array, $column, $sort = SORT_STRING, $direction = SORT_ASC
    )
    {
        if (!sizeof($array)) {
            return;
        }

        $index = [];
        $i = 0;
        foreach ($array as $key => $row) {
            if (is_array($row)) {
                $index['pos'][$i]  = $key;
                $index['name'][$i] = $row[$column];
                ++$i;
            }
        }
        array_multisort($index['name'], $sort, $direction, $index['pos']);
        $result = array();
        for ($j = 0; $j < $i; ++$j) {
            $result[$index['pos'][$j]] = $array[$index['pos'][$j]];
        }
        $array = $result;
    }
public static function sortByCol ( array & $ array , $ column , $ sort = SORT_STRING , $ direction = SORT_ASC ) { if ( ! sizeof ( $ array ) ) { return ; } $ index = [ ] ; $ i = 0 ; foreach ( $ array as $ key => $ row ) { if ( is_array ( $ row ) ) { $ index [ 'pos' ] [ $ i ] = $ key ; $ index [ 'name' ] [ $ i ] = $ row [ $ column ] ; ++ $ i ; } } array_multisort ( $ index [ 'name' ] , $ sort , $ direction , $ index [ 'pos' ] ) ; $ result = array ( ) ; for ( $ j = 0 ; $ j < $ i ; ++ $ j ) { $ result [ $ index [ 'pos' ] [ $ j ] ] = $ array [ $ index [ 'pos' ] [ $ j ] ] ; } $ array = $ result ; }
Sort two-dimensional array by column preserving row keys.

@param array  $array     <b>[by ref]</b> Array
@param string $column    Sort column
@param int    $sort      Sort type
@param int    $direction Sort direction: SORT_ASC or SORT_DESC

@return void

@link http://php.net/manual/en/function.array-multisort.php
PHP documentation for sort types
Sort two - dimensional array by column preserving row keys .