ios - How do you sort NSMutableArray from JSON in swift? -


I have created a UITable view with NSMutableArray, which has the data downloaded from the server as JSON. When I follow the table cell, the code goes down as follows.

  If rstrntName = self.items [indexPath.row] ["rstrnt_name"] as? NSString {cell.rstrntName.text = rstrntName}  

Now I want to sort it with a column named "rstrnt_name". Below is the code that I have tried, but it does not work. The NSDictionary rstrnt2 in the form of rstnt1: NSDictionary = obj1 in the self.items.sortedArrayUsingComparator ({obj1, obj2- & gt; NsympiRon) is: NSDictionary = obj2 as NSDictionary if (rstrnt1 ["String as rstrnt_name"} as a string) (as rstrnt2 ["rstrnt_name"] string) {return NSComparisonResult.OrderedAscending} if (rstrnt1 ["rstrnt_name"] string)> (rstrnt2 [ "Rstrnt_name"] returns {{NSComparisonResult.OrderedDescending} as a string NSComparisonResult.OrdiredSame})

How do I sort objects in such a type?

Assign and sort the sorted array anywhere -

  self.items = self.items.sortedArrayUsingComparator (// the rest of your code  

You should return the sort results.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -