From 1cdc1c943e54d1b1dbf7db71ac763044e3523616 Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Tue, 21 May 2024 13:05:47 -0400 Subject: Allow ordering term dictionaries with the same priority using the ui order (#981) * Remove score from dictionary sorting * Update tests * Allow score sorting after dict order * Update tests * Sort by score before index * Move headwordIndices and headwords below score * Update tests * Move definition count back under headwords --- ext/js/language/translator.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'ext') diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 31fc6d81..350cbc57 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -1932,6 +1932,10 @@ export class Translator { i = v2.dictionaryPriority - v1.dictionaryPriority; if (i !== 0) { return i; } + // Sort by dictionary order + i = v1.dictionaryIndex - v2.dictionaryIndex; + if (i !== 0) { return i; } + // Sort by term score i = v2.score - v1.score; if (i !== 0) { return i; } @@ -1952,10 +1956,6 @@ export class Translator { // Sort by definition count i = v2.definitions.length - v1.definitions.length; - if (i !== 0) { return i; } - - // Sort by dictionary order - i = v1.dictionaryIndex - v2.dictionaryIndex; return i; }; dictionaryEntries.sort(compareFunction); @@ -1979,6 +1979,10 @@ export class Translator { i = v2.dictionaryPriority - v1.dictionaryPriority; if (i !== 0) { return i; } + // Sort by dictionary order + i = v1.dictionaryIndex - v2.dictionaryIndex; + if (i !== 0) { return i; } + // Sort by term score i = v2.score - v1.score; if (i !== 0) { return i; } @@ -1994,10 +1998,6 @@ export class Translator { if (i !== 0) { return i; } } - // Sort by dictionary order - i = v1.dictionaryIndex - v2.dictionaryIndex; - if (i !== 0) { return i; } - // Sort by original order i = v1.index - v2.index; return i; -- cgit v1.2.3