iphone - Sorting mutable array by dictionary key -


i have looked through few answers using various sorting methods of nsmutablearray, reason not working me.

i trying sort mutable array contains dictionaries delay key within each dictionary. however, "sorted" array exact same original array.

by way, works fine if create dummy mutable array , populate dictionaries containing numbers, reason won't sort mutable array initializing.

what doing wrong?

here's code:

playlistcalls = [[nsmutablearray alloc] initwitharray:[currentplaylist objectforkey:@"tunes"]];  nslog(@"original %@", playlistcalls);  nssortdescriptor *delay = [nssortdescriptor sortdescriptorwithkey:@"delay" ascending:yes]; [playlistcalls sortusingdescriptors:[nsarray arraywithobject:delay]];  nslog(@"sorted %@", playlistcalls); 

here's array containing dictionaries:

2012-06-04 15:48:09.129 myapp[57043:f503] original (         {         name = test tune;         delay = 120;         volume = 100;     },         {         name = testes;         delay = 180;         volume = 100;     },         {         name = testing;         delay = 60;         volume = 100;     } )  2012-06-04 15:48:09.129 myapp[57043:f503] sorted (         {         name = test tune;         delay = 120;         volume = 100;     },         {         name = testes;         delay = 180;         volume = 100;     },         {         name = testing;         delay = 60;         volume = 100;     } ) 

the code above fine when use nsnumbers in dictionary. leads me believe delay value stored strings in dictionary. need sort strings integervalue.

nssortdescriptor *delay =     [nssortdescriptor sortdescriptorwithkey:@"delay.integervalue" ascending:yes]; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -