private synchronized @NotNull Pair<List<LookupElement>, Integer> doArrangeItems(@NotNull LookupElementListPresenter lookup,
                                                                                  boolean onExplicitAction) {
    return computeWithSpan(TelemetryManager.getInstance().getTracer(CodeCompletion), "arrangeItems", span -> {
      List<LookupElement> items = getMatchingItems();
      Iterable<? extends LookupElement> sortedByRelevance = sortByRelevance(groupItemsBySorter(items));

      sortedByRelevance = applyFinalSorter(sortedByRelevance);

      LookupElement relevantSelection = findMostRelevantItem(sortedByRelevance);
      List<LookupElement> listModel = isAlphaSorted() ?
                                      sortByPresentation(items) :
                                      fillModelByRelevance(lookup, new ReferenceOpenHashSet<>(items), sortedByRelevance, relevantSelection);

      int toSelect = getItemToSelect(lookup, listModel, onExplicitAction, relevantSelection);
      LOG.assertTrue(toSelect >= 0);

      return new Pair<>(listModel, toSelect);
    });
  }
private synchronized @NotNull Pair<List<LookupElement>, Integer> doArrangeItems(@NotNull LookupElementListPresenter lookup,
                                                                                  boolean onExplicitAction)