diff --git a/src/core/operations/SeqUtils.js b/src/core/operations/SeqUtils.js index 96fae0aa..351b0afe 100755 --- a/src/core/operations/SeqUtils.js +++ b/src/core/operations/SeqUtils.js @@ -26,7 +26,7 @@ const SeqUtils = { * @constant * @default */ - SORT_ORDER: ["Alphabetical (case sensitive)", "Alphabetical (case insensitive)", "IP address"], + SORT_ORDER: ["Alphabetical (case sensitive)", "Alphabetical (case insensitive)", "IP address", "Numeric"], /** * Sort operation. @@ -47,6 +47,8 @@ const SeqUtils = { sorted = sorted.sort(SeqUtils._caseInsensitiveSort); } else if (order === "IP address") { sorted = sorted.sort(SeqUtils._ipSort); + } else if (order === "Numeric") { + sorted = sorted.sort(SeqUtils._numericSort); } if (sortReverse) sorted.reverse(); @@ -221,6 +223,33 @@ const SeqUtils = { return a_ - b_; }, + /** + * Comparison operation for sorting of numeric values. + * + * @private + * @param {string} a + * @param {string} b + * @returns {number} + */ + _numericSort: function _numericSort(a, b) { + let a_ = a.split(/([^\d]+)/), + b_ = b.split(/([^\d]+)/); + + for (let i=0; i