Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nikke777

macrumors newbie
Original poster
May 2, 2011
2
0
Hi there...

I have got an array with numbers in it. These numbers are saved as a String.

First I had them like "1", "5", ...
Then I changed it to "001", "005", ...

How can I sort that array the right way... The way I tried it does not give the right result. It is like: "001", "010", "011", "002", "003",... (the same without the leading zeros...)

The other idea was to change the String to a int or double, but I dont know how to that... Is there a way to copy a array with changing all the entries by calling a function for every entrie like (doubleValue) ??

Would prefer to sort the string array the right way.... :)

Hope you guys can help me!

Cheers!

EDIT:

finally got the change from string to nsnumber.. sorry for that.. but i cant figure out how to sort a string array with my content right...

hopefully u guys can help me with that problem.

cheers :eek:
 
Last edited by a moderator:
You need to use the NSNumericSearch comparison option to sort strings as numbers. You probably need to write a comparison function or block that compares using this option in order to sort an array.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.