diff options
Diffstat (limited to 'src/js/NextSearch/Sort/SortDescending.js')
-rw-r--r-- | src/js/NextSearch/Sort/SortDescending.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/js/NextSearch/Sort/SortDescending.js b/src/js/NextSearch/Sort/SortDescending.js new file mode 100644 index 0000000..2b75024 --- /dev/null +++ b/src/js/NextSearch/Sort/SortDescending.js @@ -0,0 +1,17 @@ +import AbstractSearchSort from '@js/NextSearch/Sort/AbstractSearchSort'; + +export default class SortDescending extends AbstractSearchSort { + + get TYPE() { + return 'descending'; + } + + _compareValues(a, b) { + if(a === b) return 0; + if(typeof a === 'string') { + if(b === null) return 1; + return b.localeCompare(a, undefined, {numeric: true, sensitivity: 'base'}); + } + return b < a ? -1 : 1; + } +}
\ No newline at end of file |