Drupal 8  8.0.2
SortArray Class Reference

Static Public Member Functions

static sortByWeightElement (array $a, array $b)
 
static sortByWeightProperty ($a, $b)
 
static sortByTitleElement ($a, $b)
 
static sortByTitleProperty ($a, $b)
 
static sortByKeyString ($a, $b, $key)
 
static sortByKeyInt ($a, $b, $key)
 

Detailed Description

Provides generic array sorting helper methods.

Member Function Documentation

static sortByKeyInt (   $a,
  $b,
  $key 
)
static

Sorts an integer array item by an arbitrary key.

Parameters
array$aFirst item for comparison.
array$bSecond item for comparison.
string$keyThe key to use in the comparison.
Returns
int The comparison result for uasort().

Referenced by WidgetBase\extractFormValues(), and ConfigDependencyManager\sortGraph().

Here is the caller graph for this function:

static sortByKeyString (   $a,
  $b,
  $key 
)
static

Sorts a string array item by an arbitrary key.

Parameters
array$aFirst item for comparison.
array$bSecond item for comparison.
string$keyThe key to use in the comparison.
Returns
int The comparison result for uasort().

Referenced by ConfigDependencyManager\sortGraph().

Here is the caller graph for this function:

static sortByTitleElement (   $a,
  $b 
)
static

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

Callback for uasort().

Parameters
array$aFirst item for comparison. The compared items should be associative arrays that optionally include a 'title' key.
array$bSecond item for comparison.
Returns
int The comparison result for uasort().

Referenced by SortArrayTest\testSortByTitleElement().

Here is the caller graph for this function:

static sortByTitleProperty (   $a,
  $b 
)
static

Sorts a structured array by '#title' property.

Callback for uasort().

Parameters
array$aFirst item for comparison. The compared items should be associative arrays that optionally include a '#title' key.
array$bSecond item for comparison.
Returns
int The comparison result for uasort().

Referenced by SortArrayTest\testSortByTitleProperty().

Here is the caller graph for this function:

static sortByWeightElement ( array  $a,
array  $b 
)
static

Sorts a structured array by the 'weight' element.

Note that the sorting is by the 'weight' array element, not by the render element property '#weight'.

Callback for uasort().

Parameters
array$aFirst item for comparison. The compared items should be associative arrays that optionally include a 'weight' element. For items without a 'weight' element, a default value of 0 will be used.
array$bSecond item for comparison.
Returns
int The comparison result for uasort().

Referenced by SortArrayTest\testSortByWeightElement().

Here is the caller graph for this function:

static sortByWeightProperty (   $a,
  $b 
)
static

Sorts a structured array by '#weight' property.

Callback for uasort().

Parameters
array$aFirst item for comparison. The compared items should be associative arrays that optionally include a '#weight' key.
array$bSecond item for comparison.
Returns
int The comparison result for uasort().

Referenced by SortArrayTest\testSortByWeightProperty().

Here is the caller graph for this function:


The documentation for this class was generated from the following file: