I\'m looking for a way to sort a Swift array based on a Boolean value.
I\'ve got it working using a cast to NSArray:
var boolSort = NSSortDescriptor(
New (for Swift 1.2)
return results.sort { $0.selected && !$1.selected }
Old (for Swift 1.0)
Assuming results is of type [VDLProfile] and VDLProfile has a Bool member selected:
results
[VDLProfile]
Bool
selected
return results.sorted { $0.selected < $1.selected }
See documentation for sorted