I have created a studentDB table in a SQLite database and storing the data of studentDB in an NSMutableArray.
I have created attributes in our studentDB main attributs are as follows: Student_Name, Registration_No, Date_of_Join.
Now, I want to sort this mutable array according to Student_Name in ascending order in a Table View.
So, how can I do this. any help would be appreciated.
Tarun Kumar
08-Dec-2015For sorting arrays use NSSortDescriptor's method sortUsingDescriptors:sortDescriptors to sort a mutable array.
for Ex:
We can sort using different methods:
- (NSArray *)sortedArrayUsingFunction:(NSInteger (*)(id, id, void *))comparator context:(void *)context
- (NSArray *)sortedArrayUsingSelector:(SEL)comparator
- (NSArray *)sortedArrayUsingComparator:(NSComparator)cmptr
- (NSArray *)sortedArrayWithOptions:(NSSortOptions)opts usingComparator:(NSComparator)cmptr