public static @NotNull Comparator<PsiElement> projectElementsFirst(@NotNull Project project) {
    FileIndexFacade index = FileIndexFacade.getInstance(project);
    return Comparator.comparing((PsiElement element) -> {
      PsiFile containingFile = element.getContainingFile();
      if (containingFile != null) {
        VirtualFile virtualFile = containingFile.getVirtualFile();
        if (virtualFile != null && index.isInContent(virtualFile)) return true;
      }
      return false;
    }).reversed();
  }
public static @NotNull Comparator<PsiElement> projectElementsFirst(@NotNull Project project)