Does anybody know JavaScript's sort function?
Any implementation in C?
I like the compare function to sort complex thing, its easy to do and undestand and they said JavaScript's sort is the fastest sorting algorithm ever, is that right?
Does anybody know JavaScript's sort function?
Any implementation in C?
I like the compare function to sort complex thing, its easy to do and undestand and they said JavaScript's sort is the fastest sorting algorithm ever, is that right?
C's qsort function also takes a compare function, except that being a lower level language, it isn't as easy to do and understand.I like the compare function to sort complex thing, its easy to do and undestand
I don't know JavaScript, but I would suspect sort is a method, not an algorithm. I would expect it to use internally some sorting algorithm. (That is, I don't see a reason why the sort routine in other languages couldn't be implemented using the same algorithm.)they said JavaScript's sort is the fastest sorting algorithm ever, is that right?
C's qsort function, as the name implies, should be an implementation of the quicksort algorithm. C++'s sort function may be implemented using any sorting algorithm that meets the complexity/behaviour requirements (but there is no reason to assume STL implementors wouldn't choose the best algorithms available).
But you can be sure that a general-purpose sorting algorithm cannot be faster than a special-purpose algorithm for specific situations. For example, you can sort integers (in a limited range?) with linear complexity O(n), whereas a general sorting algorithm can never be better than O(n * log n).
Last edited by anon; 07-27-2008 at 04:01 AM.
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.