List<Import> (@NotNull List<Import> imports, @NotNull JavaCodeStyleSettings settings) { int[] entryForName = ArrayUtil.newIntArray(imports.size()); PackageEntry[] entries = settings.IMPORT_LAYOUT_TABLE.getEntries(); for(int i = 0; i < imports.size(); i++){ Import anImport = imports.get(i); entryForName[i] = findEntryIndex(anImport.name, anImport.isStatic, entries); } List<Import> resultList = new ArrayList<>(imports.size()); for(int i = 0; i < entries.length; i++){ for(int j = 0; j < imports.size(); j++){ if (entryForName[j] == i){ resultList.add(imports.get(j)); imports.set(j, null); } } } for (Import name : imports) { if (name != null) resultList.add(name); } return resultList; }