int (LookupElement lookupItem1, LookupElement lookupItem2) { String s1 = lookupItem1.getLookupString(); String s2 = lookupItem2.getLookupString(); int diff1 = 0; for (int i = 0; i < Math.min(s1.length(), myOldReferenceName.length()); i++) { if (s1.charAt(i) != myOldReferenceName.charAt(i)) diff1++; } int diff2 = 0; for (int i = 0; i < Math.min(s2.length(), myOldReferenceName.length()); i++) { if (s2.charAt(i) != myOldReferenceName.charAt(i)) diff2++; } return diff1 - diff2; }