4

Is there any built in sort function in Objective C with complexity of O(n log n)?

Saiful
  • 1,891
  • 1
  • 15
  • 39
  • 4
    These should be a start: http://stackoverflow.com/questions/805547/how-to-sort-an-nsmutablearray-with-custom-objects-in-it , http://stackoverflow.com/questions/1351182/how-to-sort-a-nsarray-alphabetically , http://stackoverflow.com/questions/1844031/how-to-sort-nsmutablearray-using-sortedarrayusingdescriptors , http://stackoverflow.com/questions/1132806/sort-nsarray-of-date-strings-or-objects (I did a quick search for "objective-c sort nsarray") –  Jan 16 '12 at 04:21
  • 1
    an interesting article about array in the apple world and how they behave. http://ridiculousfish.com/blog/posts/array.html – vikingosegundo Jan 16 '12 at 04:52

2 Answers2

1

Apple doesn't provide any kind of information about the complexity on his sorting functions,

You should asume that the sorting algorithm will be chosen by the framework to give the best performance, in any case you can take a look at CHDataStructures if you need extra data structures to implement the sorting algorithm on your own, probably a heap or a binary tree sort.

Ecarrion
  • 4,940
  • 1
  • 33
  • 44
0

There are several sort methods of NSArray. There is no direct documentation of their complexity, but presumably they're "reasonable".

Hot Licks
  • 47,103
  • 17
  • 93
  • 151