Skip to content

Instantly share code, notes, and snippets.

View jordanekay's full-sized avatar
🟢
Currently available for new projects

Jordan Kay jordanekay

🟢
Currently available for new projects
View GitHub Profile
@jordanekay
jordanekay / gist:5703459
Last active December 18, 2015 01:19
Naturally sorting a list of titles in Cocoa
#import <Foundation/Foundation.h>
@implementation NSString (JEKNormalization)
- (NSString *)jek_normalizedString
{
__block NSString *normalizedString = self;
[self enumerateLinguisticTagsInRange:NSMakeRange(0, self.length) scheme:NSLinguisticTagSchemeLexicalClass options:~NSLinguisticTaggerOmitWords orthography:nil usingBlock:^(NSString *tag, NSRange tokenRange, NSRange sentenceRange, BOOL *stop) {
if (tag == NSLinguisticTagDeterminer && tokenRange.location == 0) {
normalizedString = [self substringFromIndex:tokenRange.length + 1];