bp_alpha_sort_by_key( array $items, string|int $key )

Sort an array of objects or arrays by alphabetically sorting by a specific key/property.

Description

For instance, if you have an array of WordPress post objects, you can sort them by post_name as follows: $sorted_posts = bp_alpha_sort_by_key( $posts, ‘post_name’ );

Parameters

$items

(Required) The items to be sorted. Its constituent items can be either associative arrays or objects.

$key

(Required) The array index or property name to sort by.

Return

(array) $items The sorted array.

Source

File: bp-core/bp-core-functions.php

function bp_alpha_sort_by_key( $items, $key ) {
	return bp_sort_by_key( $items, $key, 'alpha' );
}

Changelog

Changelog
Version Description
BuddyPress 1.9.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.