(nouns) sort after key

This commit is contained in:
Valentyne Stigloher 2025-07-31 20:44:30 +02:00
parent 52e8147e84
commit 9dad056194
2 changed files with 6 additions and 1 deletions

View File

@ -32,6 +32,7 @@ type NounRowWithAuthor = NounRow & { author: User['username'] };
export const parseNounRow = (nounRow: NounRow): Omit<NounRaw, 'sourcesData'> => {
return {
id: nounRow.id,
key: nounRow.key,
words: JSON.parse(nounRow.words),
classInstance: nounRow.classInstance ? JSON.parse(nounRow.classInstance) : null,
categories: nounRow.categories?.split('|') ?? [],

View File

@ -844,6 +844,7 @@ export class PronounLibrary {
export interface NounRaw {
id: string;
key?: string | null;
words: NounWordsRaw;
classInstance?: NounClassInstance | null;
categories?: string[];
@ -921,6 +922,7 @@ const hasWordOfGender = (words: NounWords, gender: Gender): boolean => {
export class Noun implements Entry {
id: string;
key: string;
words: NounWords;
classInstance: NounClassInstance | null;
categories: string[];
@ -932,6 +934,7 @@ export class Noun implements Entry {
constructor(config: Config, nounRaw: NounRawWithLoadedWords) {
this.id = nounRaw.id;
this.key = nounRaw.key ?? '';
this.words = nounRaw.words;
this.classInstance = nounRaw.classInstance ?? null;
this.categories = nounRaw.categories ?? [];
@ -996,7 +999,7 @@ export class Noun implements Entry {
if (!this.approved && other.approved) {
return -1;
}
return collator.compare(this.firstWords[0], other.firstWords[0]);
return collator.compare(this.key, other.key);
}
}
@ -1036,6 +1039,7 @@ export class NounTemplate {
fill(stem: string): Omit<NounRawWithLoadedWords, 'id'> {
return {
key: stem,
words: {
masc: {
singular: this.masc.map((e) => ({ spelling: e.replace('-', stem) })),