A closure can be specified with many syntax forms. Swift provides many reduced forms—these save us from typing characters. The short forms may be easier to read.
var values = [10, 0, 20]
// Sort with short closure syntax.
values.sort(by: { v1, v2 in return v1 < v2 } )
print(values)
var values2 = [40, 0, 80]
// The return keyword is not required.
values2.sort(by: { v1, v2 in v1 < v2 } )
print(values2)
var values3 = [50, 0, 90]
// The special variables $0 and $1 are used.
// ... These indicate the first and second arguments.
values3.sort(by: { $0 < $1 } )
print(values3)
var values4 = [20, 0, 40]
// We can use ascending and descending sorts with a single char.
values4.sort(by: <)
print(values4)
[0, 10, 20]
[0, 40, 80]
[0, 50, 90]
[0, 20, 40]