wp_list_sort( array $input_list, string|array $orderby = array(), string $order = 'ASC', bool $preserve_keys = false )

Sorts an array of objects or arrays based on one or more orderby arguments.


Parameters

$input_list

(Required) An array of objects or arrays to sort.

$orderby

(Optional) Either the field name to order by or an array of multiple orderby fields as $orderby => $order.<br>

Default value: array()

$order

(Optional) Either 'ASC' or 'DESC'. Only used if $orderby is a string. Default 'ASC'.

Default value: 'ASC'

$preserve_keys

(Optional) Whether to preserve keys.

Default value: false


Return

(array) The sorted array.


Source

File: wp-includes/functions.php

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

Changelog

Changelog
Version Description
4.7.0 Introduced.