I am using Swift 3. I have a dictionary of arrays, and I am trying to sort the arrays in place using a property each object in the array contains.
As far as I understand it as of Swift 3 sorted() does not sort in place, but instead returns a sorted array value. If you want to sort in place you should use sort(). But when I try the compiler keeps saying "sort() has been renamed sorted(by:)
Why won't the compiler let me use sort()
Here is my code:
func sortAllArraysInDict() {
for arrayOfGrowthPaths in catDict.values {
arrayOfGrowthPaths.sort({$0.growthPathDisplayOrder < $1.growthPathDisplayOrder})
}
Make sure you declare your array as variable and just delete the parentheses (trailing closure syntax):