wp_recursive_ksort()WP 6.0.0

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.

No Hooks.

Return

null. Nothing.

Usage

wp_recursive_ksort( $array );
$array(array) (required) (passed by reference — &)
The array to sort, passed by reference.

Changelog

Since 6.0.0 Introduced.

Code of wp_recursive_ksort() WP 6.0

function wp_recursive_ksort( &$array ) {
	foreach ( $array as &$value ) {
		if ( is_array( $value ) ) {
			wp_recursive_ksort( $value );
		}
	}
	ksort( $array );
}