iphone - Indexing an alphabetically sorted list -


I have a list of orleases in which alphabetical alphabetical list is a list of objects (a lowerCaseString method) and I need to sort it for +1 characters for 1 alpha characters in an array of arrays.

An easy way to do this would be to loop through the source array with a huge 27 stack deep if not more then if not ... . There is no need to say that I do not think this is a very good solution, so I was thinking that I can change the first letter of the string that I am sorting on an intratted basis, then I will select that object I can use to sort the objects. .

So I need help in implementing it or finding a better way to do it.

I am working on the iPhone platform so I have access to cocoa and core apple libraries.

You can use the "sorted" NMTTable array and this is your 27 "letter" NSMutableArray object

You can use an NSArray of 26 characters (like NSString objects) and you can use indexOfObject: to get the pointer from the "sorted" array . The object must be added in the "letter" array (if it returns NSNotFound, then 26 is used as an index since your non-alpha array). For example, if you are sorting the NSString object, then you do this:

  NSArray * or IginalArray = [NSArray arrayWithObjects: @ "One object", @ "B object" , @ "C object", @ "123 object", zero]; // init with all 26 lowercase letters NSArray * characters = [with NSARR array: object: @ "A", @ "b", @ "c", zero]; // Sorted and create letter arrays NSMutableArray * SortedArray = [[NSMUTABARAআরROL] Init with Capacity: [Counts count] 1]; (Int i = 0; i & lt; [Counts of count] + 1; i ++) {// Use an appropriate capability here NSMutableArray * letterArray = [[NSMutableArray alloc] initWithCapacity: 10]; [Sortedray add object: letterar]]; [Letter era release]; } // Sort sorted arrays in the Array (NSString * string in the original array) {NSString * firstLetter = [[String SubstringWindrange: [String Range of Compassed SequenceAntandx: 0]] Lowercase String; Int index = [letter index of object: first time]; If (index == NSNotFound) {// use non-alpha array index = [count of letters]; } NSMutableArray * letterArray = [sorted array objectattex: index]; [LetterArray addObject: string]; } NSLog (@ "% @", sorted array);  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -