Monday 29 August 2011

Sorting Array in increasing order

Most of the time sorting is needed and for that most of the person think of various sorting algorithms.
This blog describe how to sort an array which contain numbers into ascending order with minimum coding effort.

NSSortDescriptor *sortDescriptor;
sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:nil
ascending:YES] autorelease];
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
NSArray *sortedArray;
sortedArray = [sortValuesArray sortedArrayUsingDescriptors:sortDescriptors];
NSLog(@"sortedArray%@",sortedArray);


Happy Coding!!

No comments:

Post a Comment