8.5.x SortArray.php SortArray::sortByTitleElement($a, $b)
8.0.x SortArray.php SortArray::sortByTitleElement($a, $b)
8.1.x SortArray.php SortArray::sortByTitleElement($a, $b)
8.2.x SortArray.php SortArray::sortByTitleElement($a, $b)
8.3.x SortArray.php SortArray::sortByTitleElement($a, $b)
8.4.x SortArray.php SortArray::sortByTitleElement($a, $b)
8.6.x SortArray.php SortArray::sortByTitleElement($a, $b)

Sorts a structured array by 'title' key (no # prefix).

Callback for uasort().

Parameters

array $a: First item for comparison. The compared items should be associative arrays that optionally include a 'title' key.

array $b: Second item for comparison.

Return value

int The comparison result for uasort().

1 call to SortArray::sortByTitleElement()
SortArrayTest::testSortByTitleElement in core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
Tests SortArray::sortByTitleElement() input against expected output.

File

core/lib/Drupal/Component/Utility/SortArray.php, line 66

Class

SortArray
Provides generic array sorting helper methods.

Namespace

Drupal\Component\Utility

Code

public static function sortByTitleElement($a, $b) {
  return static::sortByKeyString($a, $b, 'title');
}