diff --git a/source/Ox/js/Array.js b/source/Ox/js/Array.js index 88b810c6..d6f1d8cc 100644 --- a/source/Ox/js/Array.js +++ b/source/Ox/js/Array.js @@ -572,11 +572,13 @@ Ox.range = function() { var mappedArray = map ? array.map(map) : array, length = 0, sort = {}; // find numbers, and length of longest number array.forEach(function(value, i) { - var match, mappedValue = mappedArray[i]; + var mappedValue = mappedArray[i], matches; if (Ox.isString(mappedValue)) { - match = mappedValue.match(/\d+/g); - if (match && match.length > length) { - length = match.length; + matches = mappedValue.match(/\d+/g); + if (matches) { + length = Ox.max(matches.map(function(match) { + return match.length; + }).concat(length)); } } }); @@ -594,7 +596,7 @@ Ox.range = function() { sort[value] = mappedValue.toLowerCase() .replace(/^\W+/, '') .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) { var length;