the sorted(by:) function is actually 2 different functions.
one requires Comparable and uses < internally.
the other lets you specify the sorting logic directly (Comparable conformance not required).
... this convenience sorting by keyPath would still require 2 functions.
⭐️ 注意:
要將 < 設為函數參數預設值時,必須使用 () 小括號,否則會產生錯誤❗️
if you need to sort huge data, you have to prepare an additional space of the same size, which is a weak point of merge sort. This is one of main reasons why it is not used as frequently as the quick sort algorithm ...
📗 參考:First Course in Algorithms Through Puzzles (2019), 3.3 Sorting
👉
👉
Holy Swift ⟩
Ray ⟩
Thinkdiff ⟩
⟩ ⟩
can sort .
splits array into subarrays by comparing consecutive elements.