title: sorting nsarray in ascending order
body: <p>I have an NSdictonary object with following key values</p>
  
  <p>keys: 1.infoKey, 2.infoKey, 3.infoKey, 4.infoKey, 5.infoKey, 6.infoKey, 7.infoKey, 8.infoKey, 9.infoKey, 10.infoKey, 11.infoKey</p>
  
  <p>Note they are not sorted and can be in any order i.e. 3.infoKey, 7.infoKey, 2.infoKey etc</p>
  
  <p>What I am trying to do is sort the key values out i.e. 1,2,3,4,5,6,7,8,9,10,11 .... This is the code I have used so far but every time I do a sort, it sorts it in order that I don't want (see below)</p>
  
  <pre><code>    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
          NSString *stringsPlistPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"talkBtns.plist"];
  
          NSMutableDictionary *dictionary2 = [[NSMutableDictionary alloc] initWithContentsOfFile:stringsPlistPath];
  
  
          NSArray *myKeys = [dictionary2 allKeys];
  
  //This didn't give the right results
          //sortedKeys = [myKeys sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
  
  //This didn't give the right results either
          NSSortDescriptor* sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:nil ascending:YES selector:@selector(localizedCompare:)];
          sortedKeys = [myKeys sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
  
      // ***********
          // GET KEY VALUES TO
          // LOOP OVER
          // ***********
          /* */
          for (int i = 0; i &lt; [sortedKeys count]; i++) 
          {
              NSLog(@"[sortedKeys objectAtIndex:i]: %@", [sortedKeys objectAtIndex:i]);
          }
  
      //output I get
      [sortedKeys objectAtIndex:i]: 1.infoKey
      [sortedKeys objectAtIndex:i]: 10.infoKey
      [sortedKeys objectAtIndex:i]: 11.infoKey
      [sortedKeys objectAtIndex:i]: 2.infoKey
      [sortedKeys objectAtIndex:i]: 3.infoKey
      [sortedKeys objectAtIndex:i]: 4.infoKey
      [sortedKeys objectAtIndex:i]: 5.infoKey
      [sortedKeys objectAtIndex:i]: 6.infoKey
      [sortedKeys objectAtIndex:i]: 7.infoKey
      [sortedKeys objectAtIndex:i]: 8.infoKey
      [sortedKeys objectAtIndex:i]: 9.infoKey
  </code></pre>
  
  <p>I tried both ways and they both give the same results. I searched every where on stack overflow and google but couldn't find a fit for my needs. </p>
  
  <p>Any suggestions?</p>