views:

44

answers:

1

Hello,

I have an array containing all string values. Contents of the array are order_id, waypoint_x, waypoint_y. How do I sort it based on order_id and have the results like 1, 2, 3, 4.... (i.e. as if the field was an integer type and string)

When I use the waypoints as the array is at the moment the results come out 1, 10, 11, 12...

Regards, Stephen

+2  A: 

If you check the documentation of NSArray, you'll see there are different methods for sorting the array: sortedArrayUsingFunction, sortedArrayUsingSelector, sortedArrayUsingComparator, etc.

There's a nice example of how to use sortedArrayUsingFunction to sort with integer values in the answer to this question: http://stackoverflow.com/questions/1422840/sorting-an-array-of-doubles-or-cllocationdistance-values-on-the-iphone/1422881#1422881

Meta-Knight