WordPress at Your Fingertips

wp_list_sort() WP 1.0

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

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.
Either 'ASC' or 'DESC'. Only used if $orderby is a string.
Whether to preserve keys.
Default: false


Since 4.7.0 Introduced.

Code of wp_list_sort() WP 5.8

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 );

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

More from category: Helper Functions

No comments
    Log In