Skip to content

Commit

Permalink
Update RuleIdComparator
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Oct 18, 2024
1 parent 477e289 commit 5f3a7dd
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -551,14 +551,16 @@ public int compare(RuleId firstId, RuleId secondId) {
String[] o1StrArr = firstId.getClause().split("\\."); //$NON-NLS-1$
String[] o2StrArr = secondId.getClause().split("\\."); //$NON-NLS-1$
int min = Math.min(o1StrArr.length, o2StrArr.length);

for (int i = 0; i < min; ++i) {
if (!o1StrArr[i].equals(o2StrArr[i])) {
return Integer.parseInt(o1StrArr[i]) - Integer.parseInt(o2StrArr[i]);
try {
for (int i = 0; i < min; ++i) {
if (!o1StrArr[i].equals(o2StrArr[i])) {
return Integer.parseInt(o1StrArr[i]) - Integer.parseInt(o2StrArr[i]);
}
}
return o1StrArr.length - o2StrArr.length;
} catch (NumberFormatException e) {
return firstId.getClause().compareTo(secondId.getClause());
}

return o1StrArr.length - o2StrArr.length;
}
}

Expand Down

0 comments on commit 5f3a7dd

Please sign in to comment.