private static void sortVariableNameSuggestions( String[] names, final VariableKind variableKind, @Nullable final String propertyName, @Nullable final PsiType type) { if (names.length <= 1) { return; } if (LOG.isDebugEnabled()) { LOG.debug("sorting names:" + variableKind); if (propertyName != null) { LOG.debug("propertyName:" + propertyName); } if (type != null) { LOG.debug("type:" + type); } for (String name : names) { int count = JavaStatisticsManager.getVariableNameUseCount(name, variableKind, propertyName, type); LOG.debug(name + " : " + count); } } Comparator<String> comparator = new Comparator<String>() { @Override public int compare(String s1, String s2) { int count1 = JavaStatisticsManager.getVariableNameUseCount(s1, variableKind, propertyName, type); int count2 = JavaStatisticsManager.getVariableNameUseCount(s2, variableKind, propertyName, type); return count2 - count1; } }; Arrays.sort(names, comparator); }