private function compareNamespaces($class1, $class2)
    {
        $res = null;
        // loop from highest namespace priority to lowest
        foreach ($this->namespaces as $namespace) {
            if (strpos($class1, $namespace) === 0) {
                $res = 1;
            }
            if (strpos($class2, $namespace) === 0) {
                // subtract 1 from $res, setting it to either -1 or 0
                $res = (int) $res - 1;
            }
            if (null !== $res) {
                break; // exit as soon as we found a sort order
            }
        }
        return $res;
    }