fix(filters): sort comparator for LowCardinality fields never returns 0#2690
Conversation
… equal elements The comparator previously returned 1 (b before a) for any pair that was not (a=LC, b=!LC), including when both fields have the same cardinality. A comparator that never returns 0 is not a valid comparator — it violates the antisymmetry requirement and can produce non-deterministic ordering across JS engines. Fixed by computing the sort key as the difference of boolean-to-int conversions, which correctly returns -1/0/1 for all three cases.
|
@sushanth9 is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
|
Greptile SummaryThis PR fixes the field ordering comparator in the search filter sidebar.
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (3): Last reviewed commit: "style(app): format sort comparator to sa..." | Re-trigger Greptile |
Summary
DBSearchPageFilters/hooks.ts, the.sort()comparator that orders fields by LowCardinality-first returned1for every pair that wasn't(a=LC, b=!LC)— including when both fields share the same cardinality.(isLC(b) ? 1 : 0) - (isLC(a) ? 1 : 0), which correctly returns-1,0, or1for all three cases.Before:
After:
Test plan