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 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 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.


Top ↑

Return Return

(array) $items The sorted array.


Top ↑

Source Source

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

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

Top ↑

Changelog Changelog

Changelog
Version Description
1.9.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.