{"ScriptPreparationCode":"var defaultAddress = {\r\n \u0022fiasId\u0022: \u00220ecde158-a58f-43af-9707-aa6dd3484b56\u0022,\r\n \u0022fullAddress\u0022: \u0022\u0433 \u041C\u043E\u0441\u043A\u0432\u0430, \u0443\u043B \u0422\u0432\u0435\u0440\u0441\u043A\u0430\u044F, \u0434 11\u0022,\r\n \u0022regionKladrId\u0022: \u00227700000000000\u0022,\r\n \u0022regionWithType\u0022: \u0022\u0433 \u041C\u043E\u0441\u043A\u0432\u0430\u0022,\r\n \u0022cityKladrId\u0022: \u00227700000000000\u0022,\r\n \u0022cityWithType\u0022: \u0022\u0433 \u041C\u043E\u0441\u043A\u0432\u0430\u0022,\r\n \u0022streetWithType\u0022: \u0022\u0443\u043B \u0422\u0432\u0435\u0440\u0441\u043A\u0430\u044F\u0022,\r\n \u0022house\u0022: \u002211\u0022,\r\n \u0022room\u0022: \u0022125\u0022,\r\n \u0022postalCode\u0022: \u0022125009\u0022,\r\n \u0022geoLat\u0022: \u002255.76056\u0022,\r\n \u0022geoLon\u0022: \u002237.609811\u0022,\r\n \u0022floor\u0022: \u002212\u0022,\r\n \u0022entrance\u0022: \u00224\u0022,\r\n \u0022doorphone\u0022: \u0022125\u0022,\r\n \u0022comment\u0022: \u0022\u0414\u043E\u043C\u0430\u0448\u043D\u0438\u0439 \u0430\u0434\u0440\u0435\u0441. \u0417\u0432\u043E\u043D\u0438\u0442\u044C \u043F\u0435\u0440\u0435\u0434 \u043F\u0440\u0438\u0435\u0437\u0434\u043E\u043C.\u0022,\r\n \u0022isActual\u0022: true,\r\n \u0022updatedAt\u0022: \u0022string\u0022,\r\n \u0022block\u0022: \u0022\u0022,\r\n \u0022addressWithoutStreet\u0022: false\r\n}\r\n\r\nvar mockAddresses = new Array(100).fill(defaultAddress).map((address, idx) =\u003E {\r\n\tif (idx === 99) {\r\n\t\treturn {...address, isActual: true}\r\n\t}\r\n \treturn address;\r\n}) \r\n\r\n","TestCases":[{"Name":"index sort","Code":"function sortAddresses(addresses) {\r\n \tif (!addresses || addresses?.length === 0) {\r\n return addresses;\r\n }\r\n\r\n const unsortedAddresses = [...addresses];\r\n\r\n const actualAddressIndex = unsortedAddresses.findIndex((address) =\u003E address?.isActual === true);\r\n\r\n if (actualAddressIndex === -1) {\r\n return unsortedAddresses;\r\n }\r\n\r\n unsortedAddresses.splice(actualAddressIndex, 1);\r\n\r\n return [addresses[actualAddressIndex], ...unsortedAddresses];\r\n}\r\n\r\nsortAddresses(mockAddresses);","IsDeferred":false},{"Name":"quick sort","Code":"function sortAddresses(addresses) {\r\n\tif (!addresses || addresses?.length === 0) {\r\n return addresses;\r\n }\r\n\r\n\treturn addresses.sort((a,b) =\u003E a.isActual ? -1 : b.isActual ? 1 : 0);\r\n}\r\n\r\nsortAddresses(mockAddresses);","IsDeferred":false}]}