diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php
index d3bcbde..c536ac2 100644
--- src/bp-core/bp-core-functions.php
+++ src/bp-core/bp-core-functions.php
@@ -108,14 +108,23 @@ function bp_core_get_table_prefix() {
  * your own awkward callback function for usort().
  *
  * @since 2.2.0
+ * @since 2.7.0 Added $preserve_keys parameter.
+ *
+ * @param array      $items         The items to be sorted. Its constituent items
+ *                                  can be either associative arrays or objects.
+ * @param string|int $key           The array index or property name to sort by.
+ * @param string     $type          Sort type. 'alpha' for alphabetical, 'num'
+ *                                  for numeric. Default: 'alpha'.
+ * @param bool       $preserve_keys Whether to keep the keys or not.
  *
- * @param array      $items The items to be sorted. Its constituent items can be either associative arrays or objects.
- * @param string|int $key   The array index or property name to sort by.
- * @param string     $type  Sort type. 'alpha' for alphabetical, 'num' for numeric. Default: 'alpha'.
  * @return array $items The sorted array.
  */
-function bp_sort_by_key( $items, $key, $type = 'alpha' ) {
-	usort( $items, array( new BP_Core_Sort_By_Key_Callback( $key, $type ), 'sort_callback' ) );
+function bp_sort_by_key( $items, $key, $type = 'alpha', $preserve_keys = false ) {
+	if ( true === $preserve_keys ) {
+		uasort( $items, array( new BP_Core_Sort_By_Key_Callback( $key, $type ), 'sort_callback' ) );
+	} else {
+		usort( $items, array( new BP_Core_Sort_By_Key_Callback( $key, $type ), 'sort_callback' ) );
+	}
 
 	return $items;
 }
diff --git tests/phpunit/testcases/core/functions.php tests/phpunit/testcases/core/functions.php
index 64d6088..0c004d6 100644
--- tests/phpunit/testcases/core/functions.php
+++ tests/phpunit/testcases/core/functions.php
@@ -429,6 +429,80 @@ class BP_Tests_Core_Functions extends BP_UnitTestCase {
 	}
 
 	/**
+	 * @group bp_sort_by_key
+	 */
+	public function test_bp_sort_by_key_arrays_num_preserve_keys() {
+		$items = array(
+			'p' => array(
+				'foo' => 'bar',
+				'value' => 5,
+			),
+			'q' => array(
+				'foo' => 'bar',
+				'value' => 10,
+			),
+			'r' => array(
+				'foo' => 'bar',
+				'value' => 1,
+			),
+		);
+
+		$expected = array(
+			'r' => array(
+				'foo' => 'bar',
+				'value' => 1,
+			),
+			'p' => array(
+				'foo' => 'bar',
+				'value' => 5,
+			),
+			'q' => array(
+				'foo' => 'bar',
+				'value' => 10,
+			),
+		);
+
+		$this->assertEquals( $expected, bp_sort_by_key( $items, 'value', 'num', true ) );
+	}
+
+	/**
+	 * @group bp_sort_by_key
+	 */
+	public function test_bp_sort_by_key_num_should_respect_0_preserve_keys() {
+		$items = array(
+			's' => array(
+				'foo' => 'bar',
+				'value' => 2,
+			),
+			't' => array(
+				'foo' => 'bar',
+				'value' => 0,
+			),
+			'u' => array(
+				'foo' => 'bar',
+				'value' => 4,
+			),
+		);
+
+		$expected = array(
+			't' => array(
+				'foo' => 'bar',
+				'value' => 0,
+			),
+			's' => array(
+				'foo' => 'bar',
+				'value' => 2,
+			),
+			'u' => array(
+				'foo' => 'bar',
+				'value' => 4,
+			),
+		);
+
+		$this->assertEquals( $expected, bp_sort_by_key( $items, 'value', 'num', true ) );
+	}
+
+	/**
 	 * @group pagination
 	 * @group bp_sanitize_pagination_arg
 	 */
