Sorting....help! [SOLVED]

Discussion in 'Mac Programming' started by LostSoul80, Jan 29, 2009.

  1. macrumors 68020

    LostSoul80

    Joined:
    Jan 25, 2009
    #1
    Hi all,
    how can i sort an NSArray containing NSDictionaries, wich contain NSNumber objects as a key, ascending by the keys?

    Thanks
     
  2. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
  3. macrumors member

    Joined:
    Jan 31, 2005
    Location:
    Sweden
    #3
    Create a custom sort selector to do the comparison and use -[NSArray sortUsingSelector:]. It's probably not the fastest way to do it, but definitely the easiest.
     
  4. thread starter macrumors 68020

    LostSoul80

    Joined:
    Jan 25, 2009
    #4
    Hi, thanks for reply.
    I was already using NSSortDescriptors, but such in a wrong way - i was having troubles because i hadn't realized NSNumber has a compare: method... so i was trying to create a custom comparison method, wich had had to convert the nsnumber into an nsstring to finally do the comparison, by calling -[NSString compare:string options:NSNumericSearch]. This makes me laugh. Sorry for this topic.
     

Share This Page