public static function sortArrayByKey($array, $array_key, $direction = SORT_DESC, $sort_flags = SORT_REGULAR)
    {
        $output = [];

        if (!is_array($array) || !$array) {
            return $output;
        }

        foreach ($array as $key => $row) {
            $output[$key] = $row[$array_key];
        }

        array_multisort($output, $direction, $sort_flags, $array);

        return $array;
    }
public static function sortArrayByKey($array, $array_key, $direction = SORT_DESC, $sort_flags = SORT_REGULAR)
    {
        $output = [];

        if (!is_array($array) || !$array) {
            return $output;
        }

        foreach ($array as $key => $row) {
            $output[$key] = $row[$array_key];
        }

        array_multisort($output, $direction, $sort_flags, $array);

        return $array;
    }
public static function sortArrayByKey ( $ array , $ array_key , $ direction = SORT_DESC , $ sort_flags = SORT_REGULAR ) { $ output = [ ] ; if ( ! is_array ( $ array ) || ! $ array ) { return $ output ; } foreach ( $ array as $ key => $ row ) { $ output [ $ key ] = $ row [ $ array_key ] ; } array_multisort ( $ output , $ direction , $ sort_flags , $ array ) ; return $ array ; }
Sort an array by a key value in the array

@param mixed $array
@param string|int $array_key
@param int $direction
@param int $sort_flags
@return array
Sort an array by a key value in the array