diff options
author | Kuuuube <61125188+Kuuuube@users.noreply.github.com> | 2024-05-21 13:05:47 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-21 17:05:47 +0000 |
commit | 1cdc1c943e54d1b1dbf7db71ac763044e3523616 (patch) | |
tree | 196f4e86ac9d819cbe3cd3fa3d3d09c0e05686bc | |
parent | 8548573115f627dbcfa5a5967659e82c363ef011 (diff) |
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
-rw-r--r-- | ext/js/language/translator.js | 16 |
1 files changed, 8 insertions, 8 deletions
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; |