src/MasterConfig.php
protected function stableWeightSort(array &$array)
    {
        foreach ($array as $i => &$value) {
            $value["key"] = $i;
        }
        unset($value);

        usort($array, function(array $v1, array $v2) {
            $byWeight = $v1["weight"] - $v2["weight"];
            if ($byWeight === 0) {
                return $v1["key"] - $v2["key"];
            }
            return $byWeight;
        });
    }
protected function stableWeightSort(array &$array)
    {
        foreach ($array as $i => &$value) {
            $value["key"] = $i;
        }
        unset($value);

        usort($array, function(array $v1, array $v2) {
            $byWeight = $v1["weight"] - $v2["weight"];
            if ($byWeight === 0) {
                return $v1["key"] - $v2["key"];
            }
            return $byWeight;
        });
    }
protected function stableWeightSort ( array & $ array ) { foreach ( $ array as $ i => & $ value ) { $ value [ "key" ] = $ i ; } unset ( $ value ) ; usort ( $ array , function ( array $ v1 , array $ v2 ) { $ byWeight = $ v1 [ "weight" ] - $ v2 [ "weight" ] ; if ( $ byWeight === 0 ) { return $ v1 [ "key" ] - $ v2 [ "key" ] ; } return $ byWeight ; } ) ; }
All of these should be ordered by weight, but keep their order if they were equal, aka, a stable sort
Unfortunately, all of PHPs underlying sorting is done by QuickSort, so we have to do the sorting ourselves

@param array $array
@return array
All of these should be ordered by weight but keep their order if they were equal aka a stable sort Unfortunately all of PHPs underlying sorting is done by QuickSort so we have to do the sorting ourselves