wp_list_sort( array $input_list, string|array $orderby = array(), string $order = 'ASC', bool $preserve_keys = false ): array
- Since
- 4.7.0
- Source
wp-includes/functions.php:5390
Sorts an array of objects or arrays based on one or more orderby arguments.
Parameters
$input_listarray- An array of objects or arrays to sort.
$orderbystring|arrayoptional- Either the field name to order by or an array of multiple orderby fields as
$orderby => $order. Default empty array.Default:array() $orderstringoptional- Either 'ASC' or 'DESC'. Only used if
$orderbyis a string. Default 'ASC'.Default:'ASC' $preserve_keysbooloptional- Whether to preserve keys. Default false.Default:
false
Return
array- The sorted array.
Uses · 1
- WP_List_Util::__construct()Constructor.
Used by · 6
- WP_Customize_Manager::prepare_controls()Prepares panels, sections, and controls.
- WP_Customize_Nav_Menu_Item_Setting::sort_wp_get_nav_menu_items()Re-apply the tail logic also applied on $items by wp_get_nav_menu_items().
- WP_Customize_Nav_Menu_Setting::filter_wp_get_nav_menus()Filters the wp_get_nav_menus() result to ensure the inserted menu object is included, and the deleted one is removed.
- WP_Sitemaps_Posts::get_url_list()Gets a URL list for a post type sitemap.
- get_permalink()Retrieves the full permalink for the current post or post ID.
- wp_get_nav_menu_items()Retrieves all menu items of a navigation menu.
Source
function wp_list_sort( $input_list, $orderby = array(), $order = 'ASC', $preserve_keys = false ) { if ( ! is_array( $input_list ) ) { return array(); } $util = new WP_List_Util( $input_list ); return $util->sort( $orderby, $order, $preserve_keys );}History
Introduced in 4.7.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/functions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.