5

Possible Duplicate:
How to sort a NSArray alphabetically?

Hi all, I have an array which consist of companies name. I want to sort array alphabetically so that companies name come in alphabetic order. Please suggest me how to do this. Thanks in advance

Community
  • 1
  • 1
Gypsa
  • 11,230
  • 6
  • 44
  • 82

3 Answers3

19
[myArray sortUsingSelector:@selector(caseInsensitiveCompare:)];
omz
  • 53,243
  • 5
  • 129
  • 141
5
NSArray *sortedStrings = [strings sortedArrayUsingSelector:@selector(compare:)];
Hiren
  • 12,720
  • 7
  • 52
  • 72
Rams
  • 1,721
  • 12
  • 22
2

If the array consists of NSStrings:

[companies sortUsingSelector:@selector(compare:)];
Stanislav Yaglo
  • 3,185
  • 23
  • 19