mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
use localCompare for sorting
This commit is contained in:
@@ -4,14 +4,6 @@ import { getWeekGroupFromTimestamp, MONTHS_FULL } from "./date";
|
|||||||
const MILLISECONDS_IN_DAY = 1000 * 60 * 60 * 24;
|
const MILLISECONDS_IN_DAY = 1000 * 60 * 60 * 24;
|
||||||
const MILLISECONDS_IN_WEEK = MILLISECONDS_IN_DAY * 7;
|
const MILLISECONDS_IN_WEEK = MILLISECONDS_IN_DAY * 7;
|
||||||
|
|
||||||
const SORT_COLLATOR = new Intl.Collator("en", {
|
|
||||||
numeric: false,
|
|
||||||
sensitivity: "base",
|
|
||||||
ignorePunctuation: true,
|
|
||||||
caseFirst: false,
|
|
||||||
usage: "sort",
|
|
||||||
});
|
|
||||||
|
|
||||||
const comparators = {
|
const comparators = {
|
||||||
dateEdited: {
|
dateEdited: {
|
||||||
asc: (a, b) => a.dateEdited - b.dateEdited,
|
asc: (a, b) => a.dateEdited - b.dateEdited,
|
||||||
@@ -26,8 +18,8 @@ const comparators = {
|
|||||||
desc: (a, b) => b.dateDeleted - a.dateDeleted,
|
desc: (a, b) => b.dateDeleted - a.dateDeleted,
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
asc: (a, b) => SORT_COLLATOR.compare(getTitle(a), getTitle(b)),
|
asc: (a, b) => getTitle(a).localeCompare(getTitle(b)),
|
||||||
desc: (a, b) => SORT_COLLATOR.compare(getTitle(b), getTitle(a)),
|
desc: (a, b) => getTitle(b).localeCompare(getTitle(a)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user