I am pulling data from Firebase and in every loop I will get one piece of data in NSDictionary format (e.g. 1st loop I get {Kelvin: 10} , 2nd loop I get {John, 40}, 3rd loop I get {Mary, 27} ,etc)
I created a variable called "namedic" to store the data
var namedic = [NSDictionary]()
I then use an if statement in the loop to catch the data
if let myname = thename["name:"] as? NSDictionary {
//(thename["name:"] prints {Kelvin: 10}
self.namedic.append(myname)
}
I will then get an array of NSDictionaries
[{
"Kelvin" = 10;
}, {
"John" = 40;
}, {
"Mary" = 27;
}]
My question is, how do I sort this array of NSDictionaries in alphabetical order?
What I want is this:
[{
"John" = 40;
}, {
"Kelvin" = 10;
}, {
"Mary" = 27;
}]