protected function orderAcesCanonically()
    {
        $explicitDeny = [];
        $explicitAllow = [];
        $objectDeny = [];
        $objectAllow = [];
        $inherited = [];

        foreach ($this->aces as $ace) {
            $isDenied = $ace->isDenyAce();
            $isObject = $ace->isObjectAce();

            if ($ace->getFlags()->isInherited()) {
                $inherited[] = $ace;
            } elseif ($isDenied && $isObject) {
                $objectDeny[] = $ace;
            } elseif ($isDenied) {
                $explicitDeny[] = $ace;
            } elseif ($isObject) {
                $objectAllow[] = $ace;
            } else {
                $explicitAllow[] = $ace;
            }
        }

        return array_merge(
            $objectDeny,
            $explicitDeny,
            $objectAllow,
            $explicitAllow,
            $inherited
        );
    }