List<LookupElement> (Iterable<? extends LookupElement> source) { List<LookupElement> startMatches = new ArrayList<>(); List<LookupElement> middleMatches = new ArrayList<>(); for (LookupElement element : source) { (itemMatcher(element).isStartMatch(element) ? startMatches : middleMatches).add(element); } ContainerUtil.sort(startMatches, BY_PRESENTATION_COMPARATOR); ContainerUtil.sort(middleMatches, BY_PRESENTATION_COMPARATOR); startMatches.addAll(middleMatches); return startMatches; }