You are here

function crumbs_Container_WeightMap::sortCandidateKeys in Crumbs, the Breadcrumbs suite 7.2

Parameters

true[] $candidates: Format: $[$candidateKey] = true

Return value

mixed[][] Format: $[0|1][$candidateKey] = $weight|false

File

lib/Container/WeightMap.php, line 75

Class

crumbs_Container_WeightMap
Can determine a weight for a rule key based on wildcard weights.

Code

function sortCandidateKeys($candidates) {
  $buckets = array();
  $disabledCandidates = array();
  foreach ($candidates as $key => $cTrue) {
    $weight = $this
      ->valueAtKey($key);
    if (FALSE !== $weight) {
      $buckets[$weight][$key] = $weight;
    }
    else {
      $disabledCandidates[$key] = FALSE;
    }
  }
  ksort($buckets);
  $sorted = array();
  foreach ($buckets as $bucket) {
    $sorted += $bucket;
  }
  return array(
    $sorted,
    $disabledCandidates,
  );
}