diff --git a/benchmark/implementations/deepObject.js b/benchmark/implementations/deepObject.js index 627ddb7..5acaf26 100644 --- a/benchmark/implementations/deepObject.js +++ b/benchmark/implementations/deepObject.js @@ -1,5 +1,6 @@ const fastSort = require('fast-sort'); const sortArray = require('sort-array'); +const sortOn = require('sort-on'); const arraySort = require('array-sort'); const lodash = require('lodash'); const latestFastSortSort = require('../../dist/sort.js'); @@ -17,6 +18,7 @@ const sortImplementation = { amount: p => p.level1.level2.amount, }, }), + sortOn: (arr) => sortOn(arr, 'level1.level2.amount'), arraySort: (arr) => arraySort(arr, 'level1.level2.amount'), native: (arr) => arr.sort((a, b) => { if (a.level1.level2.amount == null) return 1; diff --git a/benchmark/implementations/flatArray.js b/benchmark/implementations/flatArray.js index 9c1c8c9..8ed238a 100644 --- a/benchmark/implementations/flatArray.js +++ b/benchmark/implementations/flatArray.js @@ -1,6 +1,7 @@ const fastSort = require('fast-sort'); const arraySort = require('array-sort'); const sortArray = require('sort-array'); +const sortOn = require('sort-on'); const lodash = require('lodash'); const latestFastSortSort = require('../../dist/sort.js'); @@ -12,6 +13,7 @@ const sortImplementation = { lodash: (arr) => lodash.sortBy(arr), arraySort: (arr) => arraySort(arr), sortArray: (arr) => sortArray(arr), + sortOn: (arr) => sortOn(arr, x => x), native: (arr) => arr.sort((a, b) => { if (a == null) return 1; if (b == null) return -1; diff --git a/benchmark/implementations/flatObject.js b/benchmark/implementations/flatObject.js index 3528c34..152d238 100644 --- a/benchmark/implementations/flatObject.js +++ b/benchmark/implementations/flatObject.js @@ -1,5 +1,6 @@ const fastSort = require('fast-sort'); const sortArray = require('sort-array'); +const sortOn = require('sort-on'); const arraySort = require('array-sort'); const lodash = require('lodash'); const latestFastSortSort = require('../../dist/sort.js'); @@ -11,6 +12,7 @@ const sortImplementation = { latestFastSort: (arr) => latestFastSortSort(arr).asc('amount'), lodash: (arr) => lodash.sortBy(arr, [(p) => p.amount]), sortArray: (arr) => sortArray(arr, { by: 'amount', order: 'asc' }), + sortOn: (arr) => sortOn(arr, 'amount'), arraySort: (arr) => arraySort(arr, 'amount'), native: (arr) => arr.sort((a, b) => { if (a.amount == null) return 1; diff --git a/benchmark/implementations/multiProperty.js b/benchmark/implementations/multiProperty.js index ddab541..09f5501 100644 --- a/benchmark/implementations/multiProperty.js +++ b/benchmark/implementations/multiProperty.js @@ -2,6 +2,7 @@ const fastSort = require('fast-sort'); const arraySort = require('array-sort'); const lodash = require('lodash'); const sortArray = require('sort-array'); +const sortOn = require('sort-on'); const latestFastSortSort = require('../../dist/sort.js'); const getRandomInt = require('../getRandomInt'); @@ -24,6 +25,7 @@ const sortImplementation = { sortArray: (arr) => sortArray(arr, { by: ['am1', 'am2'], }), + sortOn: (arr) => sortOn(arr, ['am1', 'am2']), }; module.exports.run = function({ size, numberOfRuns, librariesToRun }) { diff --git a/benchmark/index.js b/benchmark/index.js index 5ee24e8..73ec275 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -16,6 +16,7 @@ const librariesToRun = [ 'lodash', 'arraySort', 'sortArray', + 'sortOn', 'native', ]; diff --git a/benchmark/package-lock.json b/benchmark/package-lock.json index 6be2df9..4c9d271 100644 --- a/benchmark/package-lock.json +++ b/benchmark/package-lock.json @@ -32,6 +32,11 @@ "kind-of": "^5.0.2" } }, + "arrify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", + "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==" + }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -91,6 +96,14 @@ "kind-of": "^5.0.2" } }, + "dot-prop": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", + "integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==", + "requires": { + "is-obj": "^2.0.0" + } + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -119,6 +132,11 @@ "number-is-nan": "^1.0.0" } }, + "is-obj": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", + "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==" + }, "kind-of": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", @@ -151,6 +169,15 @@ "typical": "^6.0.0" } }, + "sort-on": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/sort-on/-/sort-on-4.1.1.tgz", + "integrity": "sha512-nj8myvTCEErLMMWnye61z1pV5osa7njoosoQNdylD8WyPYHoHCBQx/xn7mGJL6h4oThvGpYSIAxfm8VUr75qTQ==", + "requires": { + "arrify": "^2.0.1", + "dot-prop": "^5.0.0" + } + }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", diff --git a/benchmark/package.json b/benchmark/package.json index d29ecb4..d9266f7 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -10,7 +10,8 @@ "fast-sort": "^2.0.0", "lodash": "^4.17.21", "single-line-log": "^1.1.2", - "sort-array": "^4.0.1" + "sort-array": "^4.0.1", + "sort-on": "^4.1.1" }, "devDependencies": {}, "scripts": {