wordpress / latest / functions / wp_list_sort.html

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

$list array Required
An array of objects or arrays to sort.
$orderby string|array Optional
Either the field name to order by or an array of multiple orderby fields as $orderby => $order.

Default: array()

$order string Optional
Either 'ASC' or 'DESC'. Only used if $orderby is a string.

Default: 'ASC'

$preserve_keys bool 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 );
}

Used By

Used By Description

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