On this page
wp_list_sort( array $list, string|array $orderby = array(), string $order = 'ASC', bool $preserve_keys = false ): array
Sorts an array of objects or arrays based on one or more orderby arguments.
Parameters
$listarray Required-
An array of objects or arrays to sort.
$orderbystring|array Optional-
Either the field name to order by or an array of multiple orderby fields as $orderby => $order.
Default:
array() $orderstring Optional-
Either
'ASC'or'DESC'. Only used if $orderby is a string.Default:
'ASC' $preserve_keysbool Optional-
Whether to preserve keys.
Default:
false
Return
array The sorted array.
Source
File: wp-includes/functions.php. View all references
function wp_list_sort( $list, $orderby = array(), $order = 'ASC', $preserve_keys = false ) {
if ( ! is_array( $list ) ) {
return array();
}
$util = new WP_List_Util( $list );
return $util->sort( $orderby, $order, $preserve_keys );
}
Related
Uses
| Uses | Description |
|---|---|
| WP_List_Util::__construct() wp-includes/class-wp-list-util.php | Constructor. |
Used By
| Used By | Description |
|---|---|
| WP_Customize_Nav_Menu_Setting::filter_wp_get_nav_menus() wp-includes/customize/class-wp-customize-nav-menu-setting.php | Filters the wp_get_nav_menus() result to ensure the inserted menu object is included, and the deleted one is removed. |
| WP_Customize_Nav_Menu_Item_Setting::sort_wp_get_nav_menu_items() wp-includes/customize/class-wp-customize-nav-menu-item-setting.php | Re-apply the tail logic also applied on $items by wp_get_nav_menu_items() . |
| WP_Customize_Manager::prepare_controls() wp-includes/class-wp-customize-manager.php | Prepares panels, sections, and controls. |
| get_permalink() wp-includes/link-template.php | Retrieves the full permalink for the current post or post ID. |
| wp_get_nav_menu_items() wp-includes/nav-menu.php | Retrieves all menu items of a navigation menu. |
Changelog
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_list_sort