diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2026-06-01 23:36:39 -0300 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2026-06-01 23:36:57 -0300 |
| commit | 8ff3d7ed83b45817bce192945884c6f813343557 (patch) | |
| tree | 8a20b10e5df0c5168d7ff1d5c5558aa65817f2fd | |
| parent | d2f7ef2686a06eb72721b500109d432d22e64513 (diff) | |
data: AAAAAAAAAAAAAAAA sort dates nicely, sort name detail preview
| -rw-r--r-- | src/common-util/sort.js | 6 | ||||
| -rw-r--r-- | src/data/things/Track.js | 4 | ||||
| -rw-r--r-- | src/data/things/sorting-rule/ThingSortingRule.js | 9 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/common-util/sort.js b/src/common-util/sort.js index b87ef500..d89fa4cc 100644 --- a/src/common-util/sort.js +++ b/src/common-util/sort.js @@ -40,11 +40,15 @@ export function normalizeName(s) { // punctuation, with a single typical space, then trim the ends. s = s .replace( - /[\p{Separator}\p{Dash_Punctuation}\p{Connector_Punctuation}]+/gu, + /[/\p{Separator}\p{Dash_Punctuation}\p{Connector_Punctuation}]+/gu, ' ' ) .trim(); + // Zero-prefix sequences of digits (bounded by only select characters), + // so lesser-value numbers precede greater. + s = s.replace(/(?<=[ ({\[<]|^)\d+(?=[ )}\]>]|$)/g, match => match.padStart(5, '0')); + // Discard anything that isn't a letter, number, space, or apostrophe. s = s.replace(/[^\p{Letter}\p{Number} ']/gu, '').trim(); diff --git a/src/data/things/Track.js b/src/data/things/Track.js index ca3e82f7..7eff2000 100644 --- a/src/data/things/Track.js +++ b/src/data/things/Track.js @@ -677,6 +677,10 @@ export class Track extends Thing { : continuation()), }, + exposeDependency('nameForSorting'), + ], + + nameForSorting: [ { dependencies: ['name', 'nameDetailAcrossWiki'], compute: (continuation, {name, nameDetailAcrossWiki}) => diff --git a/src/data/things/sorting-rule/ThingSortingRule.js b/src/data/things/sorting-rule/ThingSortingRule.js index b5cc76dc..6dbaccf7 100644 --- a/src/data/things/sorting-rule/ThingSortingRule.js +++ b/src/data/things/sorting-rule/ThingSortingRule.js @@ -51,7 +51,14 @@ export class ThingSortingRule extends SortingRule { continue; } - if (lc.endsWith('name')) { + if (lc === 'name') { + sortByName(sortable, { + getName: thing => + thing.nameForSorting ?? + thing.name, + }); + continue; + } else if (lc.endsWith('name')) { sortByName(sortable, {getName: get}); continue; } |