fix a bug in sort/sortBy
This commit is contained in:
parent
5bbce78878
commit
46f2fa516e
1 changed files with 7 additions and 5 deletions
|
@ -572,11 +572,13 @@ Ox.range = function() {
|
||||||
var mappedArray = map ? array.map(map) : array, length = 0, sort = {};
|
var mappedArray = map ? array.map(map) : array, length = 0, sort = {};
|
||||||
// find numbers, and length of longest number
|
// find numbers, and length of longest number
|
||||||
array.forEach(function(value, i) {
|
array.forEach(function(value, i) {
|
||||||
var match, mappedValue = mappedArray[i];
|
var mappedValue = mappedArray[i], matches;
|
||||||
if (Ox.isString(mappedValue)) {
|
if (Ox.isString(mappedValue)) {
|
||||||
match = mappedValue.match(/\d+/g);
|
matches = mappedValue.match(/\d+/g);
|
||||||
if (match && match.length > length) {
|
if (matches) {
|
||||||
length = match.length;
|
length = Ox.max(matches.map(function(match) {
|
||||||
|
return match.length;
|
||||||
|
}).concat(length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -594,7 +596,7 @@ Ox.range = function() {
|
||||||
sort[value] = mappedValue.toLowerCase()
|
sort[value] = mappedValue.toLowerCase()
|
||||||
.replace(/^\W+/, '')
|
.replace(/^\W+/, '')
|
||||||
.replace(/\d+/g, function(match) {
|
.replace(/\d+/g, function(match) {
|
||||||
return Ox.pad(parseInt(match, 10), length);
|
return Ox.pad(match, 'left', length, '0');
|
||||||
});
|
});
|
||||||
Ox.forEach(['a', 'an', 'the'], function(article) {
|
Ox.forEach(['a', 'an', 'the'], function(article) {
|
||||||
var length;
|
var length;
|
||||||
|
|
Loading…
Reference in a new issue