/**
  * Sorts a structured array by either a set 'weight' property or by the ID.
  *
  * @param array $a
  *   First item for comparison.
  * @param array $b
  *   Second item for comparison.
  *
  * @return int
  *   The comparison result for uasort().
  */
 public static function sort(array $a, array $b)
 {
     if (isset($a['weight']) || isset($b['weight'])) {
         return SortArray::sortByWeightElement($a, $b);
     } else {
         return SortArray::sortByKeyString($a, $b, 'id');
     }
 }
 /**
  * Sorts the dependency graph by reverse weight and alphabetically.
  *
  * @param array $a
  *   First item for comparison. The compared items should be associative
  *   arrays that include a 'weight' and a 'component' key.
  * @param array $b
  *   Second item for comparison.
  *
  * @return int
  *   The comparison result for uasort().
  */
 public function sortGraph(array $a, array $b)
 {
     $weight_cmp = SortArray::sortByKeyInt($a, $b, 'weight') * -1;
     if ($weight_cmp === 0) {
         return SortArray::sortByKeyString($a, $b, 'component');
     }
     return $weight_cmp;
 }