(core) Use unicode-aware comparisons for user-visible strings.

Summary:
- Switch code that compares user strings to use localeCompare() based on Intl.Collator.
- Use en-US locale for now. (Ideally should be a document property.)
- Note that with this change, sorting is also becoming case-insensitive (which
  seems an improvement)

- Updated a sorted test fixture
- Updated a browser test with lots of unicode to expect different order.
- Added a bit of unicode to test ordering in Reference autocomplete dropdown.

Test Plan: Fixed / updated tests

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2758
This commit is contained in:
Dmitry S
2021-03-12 21:25:44 -05:00
parent 85a2492123
commit 6e844a2e76
5 changed files with 35 additions and 19 deletions

View File

@@ -13,7 +13,7 @@ import {UserError} from 'app/client/models/errors';
import {TableData} from 'app/client/models/TableData';
import {DocAction} from 'app/common/DocActions';
import {isBulkUpdateRecord, isUpdateRecord} from 'app/common/DocActions';
import {getSetMapValue, nativeCompare} from 'app/common/gutil';
import {getSetMapValue, localeCompare, nativeCompare} from 'app/common/gutil';
import {BaseFormatter} from 'app/common/ValueFormatter';
export interface ICellItem {
@@ -76,7 +76,7 @@ export class ColumnACIndexes {
}
function itemCompare(a: ICellItem, b: ICellItem) {
return nativeCompare(a.cleanText, b.cleanText) ||
nativeCompare(a.text, b.text) ||
return localeCompare(a.cleanText, b.cleanText) ||
localeCompare(a.text, b.text) ||
nativeCompare(a.rowId, b.rowId);
}