wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_list_sort › WordPress Function

Since4.7.0
Deprecatedn/a
wp_list_sort ( $input_list, $orderby = array(), $order = 'ASC', $preserve_keys = false )
Parameters: (4)
  • (array) $input_list An array of objects or arrays to sort.
    Required: Yes
  • (string|array) $orderby Optional. Either the field name to order by or an array of multiple orderby fields as `$orderby => $order`. Default empty array.
    Required: No
    Default: array()
  • (string) $order Optional. Either 'ASC' or 'DESC'. Only used if `$orderby` is a string. Default 'ASC'.
    Required: No
    Default: 'ASC'
  • (bool) $preserve_keys Optional. Whether to preserve keys. Default false.
    Required: No
    Default: false
Returns:
  • (array) The sorted array.
Defined at:
Codex:

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



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