Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#6047 closed enhancement (fixed)

More general sorting function

Reported by: boonebgorges's profile boonebgorges Owned by: boonebgorges's profile boonebgorges
Milestone: 2.2 Priority: normal
Severity: normal Version:
Component: Core Keywords:
Cc:

Description

bp_alpha_sort_by_key() is very nice, but it only works for alphabetical sorting. It would be nice to support numeric sorting as well. (See #5669 for an example use - sorting by position. We could also adopt elsewhere in BP.) I propose a more general function, with bp_alpha_sort_by_key() converted to a wrapper.

Change History (2)

#1 @boonebgorges
10 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 9191:

Introduce bp_sort_by_key().

A companion for bp_alpha_sort_by_key(), this function allows arrays of
objects or associative arrays to be sorted according to one of their keys/
properties - a kinda-sorta version of wp_list_pluck() for sorting. Supports
numeric as well as alphabetical sorts.

bp_alpha_sort_by_key() is converted to a wrapper of the new function.

Fixes #6047. See #5669.

#2 @boonebgorges
10 years ago

In 9192:

More precise error checking in bp_sort_by_key().

In order to support sorting with a value of 0, we must use isset() to verify
the existence of a value.

See #6047.

Note: See TracTickets for help on using tickets.