Element () { Element root = new Element("root"); List<Map.Entry<VirtualFile, String>> sorted = new ArrayList<>(myMap.entrySet()); sorted.sort(Comparator.comparing(e -> e.getKey().getPath())); for (Map.Entry<VirtualFile, String> e : sorted) { Element element = new Element(FILE_ELEMENT); element.setAttribute(URL_ATTR, VfsUtilCore.pathToUrl(e.getKey().getPath())); String fileTypeName = e.getValue(); if (fileTypeName != null && !PlainTextFileType.INSTANCE.getName().equals(fileTypeName)) { element.setAttribute(VALUE_ATTR, fileTypeName); } root.addContent(element); } return root; }