diff options
author | Alex Yatskov <alex@foosoft.net> | 2017-09-17 13:07:15 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2017-09-17 13:07:15 -0700 |
commit | 7c69b4f28a97e727a9f2fd29a2e497d1bc657ccc (patch) | |
tree | fd5b7073cb31ebe275e2c7c54bf8f46711e29589 /ext/bg/js/dictionary.js | |
parent | ba25fbfd1f6187e75bbf3aa2e36717c081f09e7c (diff) |
fix sort order
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r-- | ext/bg/js/dictionary.js | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 1cd1a846..57acbe5e 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -55,14 +55,6 @@ function dictRowsSort(rows, options) { function dictTermsSort(definitions, dictionaries=null) { return definitions.sort((v1, v2) => { - const sl1 = v1.source.length; - const sl2 = v2.source.length; - if (sl1 > sl2) { - return -1; - } else if (sl1 < sl2) { - return 1; - } - if (dictionaries !== null) { const p1 = (dictionaries[v1.dictionary] || {}).priority || 0; const p2 = (dictionaries[v2.dictionary] || {}).priority || 0; @@ -73,11 +65,11 @@ function dictTermsSort(definitions, dictionaries=null) { } } - const s1 = v1.score; - const s2 = v2.score; - if (s1 > s2) { + const sl1 = v1.source.length; + const sl2 = v2.source.length; + if (sl1 > sl2) { return -1; - } else if (s1 < s2) { + } else if (sl1 < sl2) { return 1; } @@ -89,6 +81,14 @@ function dictTermsSort(definitions, dictionaries=null) { return 1; } + const s1 = v1.score; + const s2 = v2.score; + if (s1 > s2) { + return -1; + } else if (s1 < s2) { + return 1; + } + return v2.expression.localeCompare(v1.expression); }); } |