{"ScriptPreparationCode":"// Unsorted Array number\r\nvar object1 = {\r\n a: 1,\r\n b: {\r\n c: 2,\r\n d: [3, 4],\r\n },\r\n};\r\n\r\nvar object2 = {\r\n a: 1,\r\n b: {\r\n c: 2,\r\n d: [4, 3],\r\n },\r\n};\r\n\r\n// Unsorted Array of objects\r\nvar object3 = {\r\n a: 1,\r\n b: {\r\n c: 2,\r\n d: [{\r\n w: 123\r\n }, {\r\n x: 444\r\n }],\r\n },\r\n};\r\n\r\nvar object4 = {\r\n a: 1,\r\n b: {\r\n c: 2,\r\n d: [{\r\n x: 444\r\n }, {\r\n w: 123\r\n }],\r\n },\r\n};\r\n\r\n// unsorted Array of Arrays of numbers\r\nvar object5 = {\r\n a: 1,\r\n b: {\r\n c: 2,\r\n d: [\r\n [1, 2, 3],\r\n [4, 5, 6],\r\n ],\r\n },\r\n};\r\n\r\nvar object6 = {\r\n a: 1,\r\n b: {\r\n c: 2,\r\n d: [\r\n [4, 5, 6],\r\n [1, 2, 3],\r\n ],\r\n },\r\n};","TestCases":[{"Name":"deepequal","Code":"const deepEqual = (obj1, obj2) =\u003E {\r\n if (obj1 === obj2) return true;\r\n\r\n if (typeof obj1 !== \u0027object\u0027 || typeof obj2 !== \u0027object\u0027 || obj1 === null || obj2 === null) {\r\n return false;\r\n }\r\n\r\n if (Array.isArray(obj1) \u0026\u0026 Array.isArray(obj2)) {\r\n if (obj1.length !== obj2.length) return false;\r\n obj1 = obj1.slice().sort();\r\n obj2 = obj2.slice().sort();\r\n return obj1.every((value, index) =\u003E deepEqual(value, obj2[index]));\r\n }\r\n\r\n if (Array.isArray(obj1) !== Array.isArray(obj2)) {\r\n return false;\r\n }\r\n\r\n const keys1 = Object.keys(obj1);\r\n const keys2 = Object.keys(obj2);\r\n\r\n if (keys1.length !== keys2.length) return false;\r\n\r\n keys1.sort();\r\n keys2.sort();\r\n\r\n return keys1.every((key, index) =\u003E {\r\n if (key !== keys2[index]) return false;\r\n return deepEqual(obj1[key], obj2[key]);\r\n });\r\n}\r\n\r\nconsole.log(deepEqual(object1, object2)); // true\r\nconsole.log(deepEqual(object3, object4)); // false\r\nconsole.log(deepEqual(object5, object6)); // true\r\n\r\n","IsDeferred":false},{"Name":"isEqual","Code":"const customizer = (objValue, othValue) =\u003E {\r\n if (_.isArray(objValue) \u0026\u0026 _.isArray(othValue)) {\r\n return _.isEqual(deepSort(objValue), deepSort(othValue));\r\n }\r\n};\r\n\r\n\r\nconst deepSort = (obj) =\u003E {\r\n if (_.isArray(obj)) {\r\n return _.sortBy(obj.map(deepSort), (item) =\u003E JSON.stringify(item));\r\n } else if (_.isObject(obj)) {\r\n return _.keys(obj)\r\n .sort()\r\n .reduce((result, key) =\u003E {\r\n result[key] = deepSort(obj[key]);\r\n return result;\r\n }, {});\r\n }\r\n return obj;\r\n};\r\n\r\n\r\n\r\n\r\nconsole.log(_.isEqualWith(object1, object2, customizer)); // true\r\nconsole.log(_.isEqualWith(object3, object4, customizer)); // true\r\nconsole.log(_.isEqualWith(object5, object6, customizer)); // true\r\n","IsDeferred":false}]}