Commit 10561b95 authored by Sebastian Kehr's avatar Sebastian Kehr 🚣🏼
Browse files

sort rules by index in case of equal priorities

parent 9ceb44e7
Pipeline #715 passed with stage
in 20 seconds
......@@ -116,14 +116,16 @@ class Evaluator
*/
protected function normalizeRules(array $rules)
{
$rules = array_values($rules);
foreach ($rules as &$rule) {
$rule[self::PRIO] = isset($rule[self::PRIO]) ? intval($rule[self::PRIO]) : 0;
}
usort($rules, function ($first, $second) {
return $second[self::PRIO] - $first[self::PRIO];
uksort($rules, function ($firstKey, $secondKey) use ($rules) {
list($first, $second) = [$rules[$firstKey], $rules[$secondKey]];
return $second[self::PRIO] - $first[self::PRIO] ?: $firstKey - $secondKey;
});
return $rules;
return array_values($rules);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment