Calling .sort() (or .sort()-style ordering) without a compare function sorts elements as strings (lexicographic), which gives wrong order for numbers/objects and is locale-unsafe. Provide a comparator (numeric, or String.localeCompare).
Surfaced by SonarQube (`learn.spikersoft.com`), rule `typescript:S2871` / `javascript:S2871`, severity CRITICAL (RELIABILITY).
## Problem
Calling `.sort()` (or `.sort()`-style ordering) without a compare function sorts elements as strings (lexicographic), which gives wrong order for numbers/objects and is locale-unsafe. Provide a comparator (numeric, or `String.localeCompare`).
## Locations
- `projects/spikersoft/src/app/_components/dreamstream-cluster-dashboard/dreamstream-cluster-dashboard.component.ts:1437`
- `projects/spikersoft/src/app/_components/dreamstream-cluster-dashboard/dreamstream-cluster-dashboard.cluster.spec.ts:505` (test)
- `libraries/features/dev-tools-sql-runner/src/lib/sql-lesson-grader.service.ts:294`
- `libraries/features/dev-tools-sql-runner/src/lib/sql-lesson-grader.service.ts:295`
- `libraries/platform/clang-runtime/src/lib/language-concept-registry.service.spec.ts:150` (test)
- `scripts/find-missing-i18n-keys.mjs:43`
## Fix
Add an explicit comparator at each site, e.g. `arr.sort((a, b) => a - b)` or `arr.sort((a, b) => a.localeCompare(b))`.
_Rule: https://rules.sonarsource.com/typescript/RSPEC-2871/_
Resolved in spikersoft-angular PR #73 (merged to master). Added explicit localeCompare comparators to all six bare .sort() sites (dreamstream dashboard, sql-lesson-grader ×2, i18n script, two specs). Closing.
Resolved in spikersoft-angular PR #73 (merged to `master`). Added explicit `localeCompare` comparators to all six bare `.sort()` sites (dreamstream dashboard, sql-lesson-grader ×2, i18n script, two specs). Closing.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Surfaced by SonarQube (
learn.spikersoft.com), ruletypescript:S2871/javascript:S2871, severity CRITICAL (RELIABILITY).Problem
Calling
.sort()(or.sort()-style ordering) without a compare function sorts elements as strings (lexicographic), which gives wrong order for numbers/objects and is locale-unsafe. Provide a comparator (numeric, orString.localeCompare).Locations
projects/spikersoft/src/app/_components/dreamstream-cluster-dashboard/dreamstream-cluster-dashboard.component.ts:1437projects/spikersoft/src/app/_components/dreamstream-cluster-dashboard/dreamstream-cluster-dashboard.cluster.spec.ts:505(test)libraries/features/dev-tools-sql-runner/src/lib/sql-lesson-grader.service.ts:294libraries/features/dev-tools-sql-runner/src/lib/sql-lesson-grader.service.ts:295libraries/platform/clang-runtime/src/lib/language-concept-registry.service.spec.ts:150(test)scripts/find-missing-i18n-keys.mjs:43Fix
Add an explicit comparator at each site, e.g.
arr.sort((a, b) => a - b)orarr.sort((a, b) => a.localeCompare(b)).Rule: https://rules.sonarsource.com/typescript/RSPEC-2871/
Resolved in spikersoft-angular PR #73 (merged to
master). Added explicitlocaleComparecomparators to all six bare.sort()sites (dreamstream dashboard, sql-lesson-grader ×2, i18n script, two specs). Closing.