{"ScriptPreparationCode":"function getRandomInt(max) {\r\n return Math.floor(Math.random() * Math.floor(max));\r\n}\r\n\r\nvar arr = [];\r\nfor(var i = 0; i \u003C 100000; i\u002B\u002B){\r\n arr.push({value:getRandomInt(100)});\r\n}\r\n\r\n","TestCases":[{"Name":"lodash orderBy","Code":"_.orderBy(arr,\u0022value\u0022,\u0022asc\u0022);","IsDeferred":false},{"Name":"Custom NativeSort","Code":"function get(selector, obj) {\r\n return selector.split(\u0027.\u0027).reduce((acc, part) =\u003E {\r\n // O(n2) when querying for an array (e.g. items[0].name)\r\n // Likely, the object depth will be reasonable enough that performance is not a concern\r\n\r\n\r\n return acc[part];\r\n }, obj);\r\n}\r\n\r\nfunction compareValues(key, order) {\r\n return (a, b) =\u003E {\r\n if (!key) {\r\n return 0;\r\n }\r\n\r\n const leftValue = get(key, a);\r\n const rightValue = get(key, b);\r\n\r\n const left = (typeof leftValue === \u0027string\u0027)\r\n ? leftValue.toUpperCase()\r\n : leftValue;\r\n const right = (typeof rightValue === \u0027string\u0027)\r\n ? rightValue.toUpperCase()\r\n : rightValue;\r\n const comparison = (left \u003E right) ? 1 : -1;\r\n\r\n return (\r\n (order === \u0027desc\u0027) ? (comparison * -1) : comparison\r\n );\r\n };\r\n}\r\n\r\narr.concat().sort(compareValues(\u0022value\u0022))","IsDeferred":false}]}