[wp-trac] [WordPress Trac] #37128: Introduce helper function `wp_list_sort()`
WordPress Trac
noreply at wordpress.org
Sun Jun 19 16:29:25 UTC 2016
#37128: Introduce helper function `wp_list_sort()`
-------------------------+------------------------------
Reporter: flixos90 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-------------------------+------------------------------
Changes (by flixos90):
* keywords: needs-patch => has-patch
Comment:
[attachment:37128.diff] adds a function `wp_list_sort()`.
The patch also adds another private function `_wp_list_sort_callback()`
which is used by `usort()` in the main function. The fields to order by
are temporarily stored in a private global `$_wp_list_sort` which is only
available while `wp_list_sort()` is doing its work.
As far as the parameters work, they are similar like the `$orderby` and
`$order` arguments of `WP_Query` for example. One can either pass
`$orderby` as a string (field name) and `$order` (`ASC` or `DESC`) or
alternatively only specify `$orderby` as an array of `orderby => order` to
support sorting by multiple fields.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37128#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list