Swift Integer Array – Sort in Decreasing Order
To sort an integer array in decreasing/descending order in Swift, call
sort(by:) method on this array and pass
sort(by:) method sorts this array in place based on the condition/predicate passed for
In the following program, we will take an array of integers and sort them in decreasing order using
var arr = [2, 8, 1, 9, 4, 7] arr.sort(by: >) print(arr)
In this Swift Tutorial, we learned how to sort an Integer Array in decreasing order using sort(by:) method.