Swift’s standard library provides a function called sort, which sorts an array of values of a
known type, based on the output of a sorting closure that you provide. Once it completes
the sorting process, the sort function returns a new array of the same type and size as the
old one, with its elements in the correct sorted order.
The closure expression examples below use the sort function to sort an array of String
values in reverse alphabetical order. Here’s the initial array to be sorted: