If you want to sort original array of custom objects. Here is another way to do so in Swift 2.1
var myCustomerArray = [Customer]()
myCustomerArray.sortInPlace {(customer1:Customer, customer2:Customer) -> Bool in
customer1.id < customer2.id
}
Where id
is an Integer. You can use the same <
operator for String
properties as well.
You can learn more about its use by looking at an example here: Swift2: Nearby Customers