void (final UsageInfo[] usages) { Arrays.sort(usages, (usage1, usage2) -> { PsiElement element1 = usage1.getElement(), element2 = usage2.getElement(); if (element1 == element2) return 0; if (element1 == null) return 1; if (element2 == null) return -1; return element2.getTextRange().getStartOffset() - element1.getTextRange().getStartOffset(); }); }