wp_recursive_ksort() WordPress Function
The wp_recursive_ksort() function sorts an array or object recursively by key. This is a useful function for sorting large multidimensional arrays by key, such as those used in Wordpress themes and plugins.
wp_recursive_ksort( array $array ) #
Sorts the keys of an array alphabetically.
Description
The array is passed by reference so it doesn’t get returned which mimics the behaviour of ksort.
Parameters
- $array
(array)(Required)The array to sort, passed by reference.
Source
File: wp-includes/functions.php
function wp_recursive_ksort( &$array ) {
foreach ( $array as &$value ) {
if ( is_array( $value ) ) {
wp_recursive_ksort( $value );
}
}
ksort( $array );
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 6.0.0 | Introduced. |