Skip to content

Commit

Permalink
fix(ant): use deterministic sort with no locale comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Feb 5, 2025
1 parent 090230f commit 7f2e067
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils/ant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ export const sortANTRecords = (antRecords: ANTRecords): SortedANTRecords => {
// if both records have a priority, sort by priority and fallback to lexicographic sorting
if (aRecord.priority !== undefined && bRecord.priority !== undefined) {
if (aRecord.priority === bRecord.priority) {
return a.localeCompare(b);
// use deterministic comparison instead of localeCompare to avoid locale-specific sorting
return a < b ? -1 : a > b ? 1 : 0;
}
return aRecord.priority - bRecord.priority;
}
// all other records are sorted lexicographically
return a.localeCompare(b);
// all other records are sorted lexicographically, using deterministic comparison instead of localeCompare to avoid locale-specific sorting
return a < b ? -1 : a > b ? 1 : 0;
},
);
// now that they are sorted, add the index to each record - this is their position in the sorted list and is used to enforce undername limits
Expand Down

0 comments on commit 7f2e067

Please sign in to comment.