Sorting Array in increasing order

前端 未结 7 428
鱼传尺愫
鱼传尺愫 2021-01-03 07:01

I have an array that contains values like 0,3,2,8 etc.I want to sort my array in increasing order.Please tell me how to do this.

Thanks in advance!!

7条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-03 07:17

    Use the code: [[myData allKeys]sortedArrayUsingSelector:@selector(psuedoNumericCompare:)];

    myData is your array. If you use that line in your code, it will sort on size of the integer (and not alphabetic, so it won't sort like 1, 111, 2,322, 333, 4445, 45, 67 but like 1, 2, 45, 67, 111, 322, 333, 4445).

    Original source: How to let the sortedArrayUsingSelector using integer to sort instead of String?

提交回复
热议问题