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.

Return

Array. The sorted array.

Usage

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

Code of wp_list_sort: wp-includes/functions.php VER 4.9.8

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

Related Functions

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

More from category: Helper Functions

No comments
    Hello, !     Log In . Register