Test name | Executions per second |
---|---|
_.sortBy | 1604973.4 Ops/sec |
array.prototype.sort | 10343582.0 Ops/sec |
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
var arr = [];
var EXECUTION_BLOCK_NAMES = ['Итого', 'Центр', 'Урал+Сибирь'];
for(var i = 0; i < 100000; i++){
arr.concat([{name: 'Итого'}, {name: 'Центр'}, {name: 'Урал+Сибирь'}]);
}
_.sortBy(arr, (i) => EXECUTION_BLOCK_NAMES.indexOf(i.name));
arr.sort((i) => EXECUTION_BLOCK_NAMES.indexOf(i.name));