WordPress at a glance

wp_list_sort() WP 1.0

Sorts a list of objects, based on one or more orderby arguments.

Works based on: WP_List_Util()

No Hooks.


Array. The sorted array.


wp_list_sort( $list, $orderby, $order, $preserve_keys );
$list(array) (required)
An array of objects to sort.
Either the field name to order by or an array of multiple orderby fields as $orderby => $order.
Default: array()
Either 'ASC' or 'DESC'. Only used if $orderby is a string.
Default: 'ASC'
Whether to preserve keys.
Default: false


Since 4.7.0 Introduced.

Code of wp list sort: wp-includes/functions.php WP 5.4.2

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 Functions

From tag: array list help functions (sorting arrays objects)

More from category: Helper Functions

No comments
        Log In . Register