title: How do I apply an array of NSSortDescriptors in a case insensitive way?
body: <p>Because <a href="https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSHTTPCookieStorage_Class/index.html" rel="nofollow"><code>NSHTTPCookieStorage</code></a> has some awful limitations I'm implementing my own and one of the methods to re-implement is <a href="https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSHTTPCookieStorage_Class/index.html#//apple_ref/occ/instm/NSHTTPCookieStorage/sortedCookiesUsingDescriptors:" rel="nofollow"><code>- (NSArray *)sortedCookiesUsingDescriptors:(NSArray *)sortOrder</code></a>. It just gets an array of <code>NSSortDescriptor</code>s and applies it but to my surprise, the results from my tests seems to indicate these sort descriptors are applied in a case insensitive fashion.</p>
  
  <p>I couldn't find any way to apply <code>NSSortDescriptor</code>s in a case insensitive way other than by setting their selectors to <code>:@selector(caseInsensitiveCompare:)</code> but since the property selector is read only, the best I managed is this:</p>
  
  <pre><code>NSMutableArray *insensitiveSortOrder = [NSMutableArray array];
  for (NSSortDescriptor* sorter in sortOrder) {
      [insensitiveSortOrder addObject: [NSSortDescriptor sortDescriptorWithKey: sorter.key ascending:sorter.ascending selector:@selector(caseInsensitiveCompare:)]];
  }
  </code></pre>
  
  <p>Is that implementation correct? Is there a better way to achieve this?</p>
  
  <p>One thing that worries me is that I'm completely ignoring the <a href="https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSSortDescriptor_Class/index.html#//apple_ref/occ/instp/NSSortDescriptor/comparator" rel="nofollow"><code>comparator</code></a> property of the NSSortDescriptor.</p>