public function sortImports(array $data, $prefix = '')
    {
        if (!isset($data['imports']) || !is_array($data['imports'])) {
            return $data;
        }

        $importsBeforePrefixed = array();
        $importsWithPrefix = array();
        $importsAfterPrefixed = array();

        foreach ($data['imports'] as $import) {
            $resource = $import['resource'];
            if (empty($prefix) || 0 === strpos($resource, $prefix)) {
                $importsWithPrefix[] = $resource;
            } elseif (count($importsWithPrefix)) {
                $importsAfterPrefixed[] = $resource;
            } else {
                $importsBeforePrefixed[] = $resource;
            }
        }

        sort($importsWithPrefix);

        $data = array_merge($importsBeforePrefixed, $importsWithPrefix, $importsAfterPrefixed);
        $data = array_map(function($resource) {
            return array('resource' => $resource);
        }, $data);

        return array('imports' => $data);
    }