How to sort numbers in NSArray?

Josh Kahane picture Josh Kahane · Jun 24, 2012 · Viewed 25.6k times · Source

I can't piece together how to do this.

I fetch my array from a plist, this array is full of numbers (as set in the plist). Now al I need to do is sort them so they are descending, but I can't work it out.

Answer

Alexsander Akers picture Alexsander Akers · Jun 24, 2012

Try this code?

 NSArray *array = /* loaded from file */;
 array = [array sortedArrayUsingSelector: @selector(compare:)];