{"ScriptPreparationCode":"var sortDirections = {\r\n DEFAULT: -1,\r\n ASC: 1,\r\n DESC: -1,\r\n};\r\n\r\nvar numberArrayToSort = [1, 4, 3, 2, 5, 6, 9, 10, 5, 8, 7, 1, 4, 3, 2, 5, 6, 9, 10, 5, 8, 7, 1, 4, 3, 2, 5, 6, 9, 10, 5, 8, 7, 1, 4, 3, 2, 5, 6, 9, 10, 5, 8, 7, 1, 4, 3, 2, 5, 6, 9, 10, 5, 8, 7, 1, 4, 3, 2, 5, 6, 9, 10, 5, 8, 7, 1, 4, 3, 2, 5, 6, 9, 10, 5, 8, 7, 1, 4, 3, 2, 5, 6, 9, 10, 5, 8, 7, 1, 4, 3, 2, 5, 6, 9, 10, 5, 8, 7];\r\n\r\n// ---------------------------------\r\n\r\nvar compare = (lessThan, equalTo) =\u003E {\r\n if (equalTo) {\r\n return 0;\r\n }\r\n\r\n if (lessThan) {\r\n return -1;\r\n }\r\n\r\n return 1;\r\n};\r\n\r\nvar compareStraight = (a, b) =\u003E {\r\n if (a === b) {\r\n return 0;\r\n }\r\n\r\n if (a \u003C b) {\r\n return -1;\r\n }\r\n\r\n return 1;\r\n};\r\n\r\n\r\nvar compareStraightNumber = (a, b) =\u003E a - b;\r\n\r\n// ---------------------------------\r\n\r\nvar primitiveTypeComparator = (a, b) =\u003E compare(a \u003C b, a === b);\r\n\r\nvar genericDirectionComparator = (comparator = primitiveTypeComparator) =\u003E (a, b, direction = sortDirections.ASC) =\u003E {\r\n return direction * comparator(a, b);\r\n};\r\n\r\nvar sortByNumberComparator = genericDirectionComparator();\r\n\r\n// ---------------------------------\r\n\r\nvar sortDirectionWrapper = (compareFunc, direction = sortDirections.ASC) =\u003E (a, b) =\u003E compareFunc(a, b) * direction;\r\nvar cleanStraightSort = (direction) =\u003E sortDirectionWrapper(compareStraight, direction);\r\nvar cleanStraightSortFast = (direction) =\u003E sortDirectionWrapper(compareStraightNumber, direction);\r\n\r\n// ---------------------------------","TestCases":[{"Name":"PR Code","Code":"numberArrayToSort.sort((a, b) =\u003E sortByNumberComparator(a, b, sortDirections.ASC));","IsDeferred":false},{"Name":"Comparison Code","Code":"numberArrayToSort.sort(sortDirectionWrapper(primitiveTypeComparator, sortDirections.ASC));","IsDeferred":false},{"Name":"Comparison Code 2, simple sort function","Code":"numberArrayToSort.sort(sortDirectionWrapper(compareStraight, sortDirections.ASC));","IsDeferred":false},{"Name":"Comparison Code 3, syntactic sugar","Code":"numberArrayToSort.sort(cleanStraightSort(sortDirections.ASC))","IsDeferred":false},{"Name":"Comparison Code 4, now even quicker?","Code":"numberArrayToSort.sort(cleanStraightSortFast(sortDirections.ASC))","IsDeferred":false}]}