I want to sort my array….
In my array elements are in this order dateArray{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}
But i want this array in reverse order
I used this code for reversing..
dateArray=[[NSMutableArray alloc]initWithArray:[[date reverseObjectEnumerator] allObjects]];
But it gives this output
dateArray=(
9,
8,
7,
6,
5,
4,
3,
2,
19,
18,
17,
16,
15,
14,
13,
12,
11,
10,
1,
0
)
But i want this output dateArray(19,18,17,16,15,14,13,12,11,10……..2,1,0)
I also used sorting method but output is same. how can i do this??? Please help
EDITED:
My array elements are the contents of NSDocument Directory….
SOLVED
this question has been sovled. I don’t know the exact way to sort my array as i want but i changed my subpaths name. and it gives right output..
Thanks in Advance
if you are want to work with strings instead of numbers, you should use the following format for the correct sorting:
20,19, …10,09,08, …02,01,00therefore, you just have to add a leading
0to every number. if they are strings, you can sort them like strings only, not like numbers, this is why the leading zero is needed.by the way the most painless solution is to rename the subpaths then, where the strings come, and you won’t need to change anything else in your application for getting the right order.