mirror of
https://github.com/Fabio286/antares.git
synced 2024-12-12 08:46:04 +01:00
fix: wrong soft sort algorithm for numeric fields, closes #199
This commit is contained in:
parent
4479a9600b
commit
763be8532d
@ -175,8 +175,10 @@ export default {
|
|||||||
if (this.currentSort && !this.isHardSort) {
|
if (this.currentSort && !this.isHardSort) {
|
||||||
return [...this.localResults].sort((a, b) => {
|
return [...this.localResults].sort((a, b) => {
|
||||||
let modifier = 1;
|
let modifier = 1;
|
||||||
const valA = typeof a[this.currentSort] === 'string' ? a[this.currentSort].toLowerCase() : a[this.currentSort];
|
let valA = typeof a[this.currentSort] === 'string' ? a[this.currentSort].toLowerCase() : a[this.currentSort];
|
||||||
const valB = typeof b[this.currentSort] === 'string' ? b[this.currentSort].toLowerCase() : b[this.currentSort];
|
if (!isNaN(valA)) valA = Number(valA);
|
||||||
|
let valB = typeof b[this.currentSort] === 'string' ? b[this.currentSort].toLowerCase() : b[this.currentSort];
|
||||||
|
if (!isNaN(valB)) valB = Number(valB);
|
||||||
if (this.currentSortDir === 'desc') modifier = -1;
|
if (this.currentSortDir === 'desc') modifier = -1;
|
||||||
if (valA < valB) return -1 * modifier;
|
if (valA < valB) return -1 * modifier;
|
||||||
if (valA > valB) return 1 * modifier;
|
if (valA > valB) return 1 * modifier;
|
||||||
|
Loading…
Reference in New Issue
Block a user