void (PsiElement[] occurrences) { Arrays.sort(occurrences, (elem1, elem2) -> { final int offset1 = elem1.getTextRange().getStartOffset(); final int offset2 = elem2.getTextRange().getStartOffset(); return offset1 - offset2; }); }