private function groupRoutes()
    {
        $routes = array();
        foreach ($this->routeTypes as $type => $typeName) {
            $routes[$type] = array();
        }

        foreach ($this->routes as $routePattern => $route) {
            if (!isset($route['type'])) {
                $route['type'] = Router::BASE_ROUTE;
            }

            $this->validateRouteType($route['type']);
            $routes[$route['type']][$routePattern] = $route;
        }

        $this->routes = $routes;
    }