I am attempting to sort a Swift array which is composed of dictionaries. I have prepared a working example below. The goal is to sort the entire array by the \"d\" element in t
when we parse the data then we can sort by using NSSortDescriptor
let dataDict1 = responseDict.valueForKey("Data")
self.customerArray = dataDict1!.valueForKey("Customers") as! NSMutableArray
var tempArray = NSMutableArray()
for index in self.customerArray {
tempArray.addObject(index.valueForKey("Customer") as! NSMutableDictionary)
}
let descriptor: NSSortDescriptor = NSSortDescriptor(key: "name", ascending: true, selector: "caseInsensitiveCompare:")
let sortedResults: NSArray = tempArray.sortedArrayUsingDescriptors([descriptor])
self.customerArray = NSMutableArray(array: sortedResults)