1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{"ScriptPreparationCode":"function shuffleArray(array) {\r\n const copy = array.slice(0);\r\n for (let i = copy.length - 1; i \u003E 0; i--) {\r\n const j = Math.floor(Math.random() * (i \u002B 1));\r\n [copy[i], copy[j]] = [copy[j], copy[i]];\r\n }\r\n return copy;\r\n}\r\n\r\nconst list = Array.from(document.querySelectorAll(\u0022ul \u003E li\u0022));\r\nconst shuffled = shuffleArray(list);","TestCases":[{"Name":"Sort by textContent","Code":"const sorted = shuffled.toSorted((a, b) =\u003E {\r\n\treturn parseInt(a.textContent) - parseInt(b.textContent);\r\n});","IsDeferred":false},{"Name":"Sort by compareDocumentPosition","Code":"const sorted = shuffled.toSorted((a, b) =\u003E {\r\n\treturn a.compareDocumentPosition(b) \u0026 Node.DOCUMENT_POSITION_PRECEDING ? 1 : -1;\r\n});","IsDeferred":false}]}