Sort NSMutableArray with strings that contain numbers?

后端 未结 4 1559
北恋
北恋 2021-01-06 02:01

I have a NSMutableArray and it has the users high scores saved into it. I want to arrange the items numerically (the numbers are stored in NSStrings.)
Example:
4,2,7,8

4条回答
  •  误落风尘
    2021-01-06 02:30

    The NSMutableArray method sortUsingSelector: should do it:

    [scoreArray sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)]
    

    should do it.

提交回复
热议问题