keys = Object.keys(this.choices);
if (this.options.sort === true)
- keys.sort();
+ keys.sort(L.naturalCompare);
else if (Array.isArray(this.options.sort))
keys = this.options.sort;
var keys = Object.keys(this.choices);
if (this.options.sort === true)
- keys.sort();
+ keys.sort(L.naturalCompare);
else if (Array.isArray(this.options.sort))
keys = this.options.sort;
rows = E('ul');
list.sort(function(a, b) {
- var isDirA = (a.type == 'directory'),
- isDirB = (b.type == 'directory');
-
- if (isDirA != isDirB)
- return isDirA < isDirB;
-
- return a.name > b.name;
+ return L.naturalCompare(a.type == 'directory', b.type == 'directory') ||
+ L.naturalCompare(a.name, b.name);
});
for (var i = 0; i < list.length; i++) {
if (wA != wB)
return wA - wB;
- return a.name > b.name;
+ return L.naturalCompare(a.name, b.name);
});
}
});
}, this));
list.sort(function(a, b) {
- if (a[0] < b[0])
- return sorting[1] ? 1 : -1;
-
- if (a[0] > b[0])
- return sorting[1] ? -1 : 1;
-
- return 0;
+ return sorting[1]
+ ? -L.naturalCompare(a[0], b[0])
+ : L.naturalCompare(a[0], b[0]);
});
data.length = 0;