wp_recursive_ksort

The timeline below displays how wordpress function wp_recursive_ksort has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Sorts the keys of an array alphabetically.
 *
 * The array is passed by reference so it doesn't get returned
 * which mimics the behavior of `ksort()`.
 *
 * @since 6.0.0
 *
 * @param array $input_array The array to sort, passed by reference.
 */
function wp_recursive_ksort(&$input_array)
{
    foreach ($input_array as &$value) {
        if (is_array($value)) {
            wp_recursive_ksort($value);
        }
    }
    ksort($input_array);
}

WordPress Version: 6.1

/**
 * Sorts the keys of an array alphabetically.
 * The array is passed by reference so it doesn't get returned
 * which mimics the behaviour of ksort.
 *
 * @since 6.0.0
 *
 * @param array $array The array to sort, passed by reference.
 */
function wp_recursive_ksort(&$array)
{
    foreach ($array as &$value) {
        if (is_array($value)) {
            wp_recursive_ksort($value);
        }
    }
    ksort($array);
}