PsiReference[] (final Collection<? extends PsiReference> allReferences) { final PsiReference[] usages = allReferences.toArray(PsiReference.EMPTY_ARRAY); Arrays.sort(usages, (usage1, usage2) -> { final PsiElement element1 = usage1.getElement(); final PsiElement element2 = usage2.getElement(); return element2.getTextRange().getStartOffset() - element1.getTextRange().getStartOffset(); }); return usages; }