{"ScriptPreparationCode":"var users = [\r\n { \u0027user\u0027: \u0027joey\u0027, \u0027age\u0027: 29 },\r\n { \u0027user\u0027: \u0027joey\u0027, \u0027age\u0027: 32 },\r\n { \u0027user\u0027: \u0027ross\u0027, \u0027age\u0027: 41 },\r\n { \u0027user\u0027: \u0027ross\u0027, \u0027age\u0027: 25 },\r\n { \u0027user\u0027: \u0027ross\u0027, \u0027age\u0027: 48 },\r\n { \u0027user\u0027: \u0027chandler\u0027, \u0027age\u0027: 39 },\r\n { \u0027user\u0027: \u0027chandler\u0027, \u0027age\u0027: 12 },\r\n { \u0027user\u0027: \u0027chandler\u0027, \u0027age\u0027: 41 }\r\n]","TestCases":[{"Name":"Sort by multiple properties","Code":"const by = (fields) =\u003E (a, b) =\u003E fields.map(o =\u003E {\r\n let dir = 1;\r\n if (o[0] === \u0027-\u0027) { dir = -1; o=o.substring(1); }\r\n return a[o] \u003E b[o] ? dir : a[o] \u003C b[o] ? -(dir) : 0;\r\n}).reduce((p, n) =\u003E p ? p : n, 0);\r\n\r\nlet sorted = users.sort(by([\u0027user\u0027, \u0027age\u0027]));\r\n\r\nconsole.log(sorted);","IsDeferred":false},{"Name":"Lodash sortBy","Code":"let sorted = _.sortBy(users, [\u0027user\u0027, \u0027age\u0027]);\r\n\r\nconsole.log(sorted);","IsDeferred":false}]}