

How to properly shuffle arrays in JavaScript - dhruvbhatia
http://sroucheray.org/blog/2009/11/array-sort-should-not-be-used-to-shuffle-an-array/

======
malka
"The Array.sort() method uses a Bubble Sort algorithm." Seriously ? why the
hell would anyone use this algorithm ?

~~~
dalke
The author appears to be completely wrong.

While the spec doesn't say anything about the expected performance, there's no
way a real Javascript implementation uses an O(n * n) algorithm.

Indeed, [http://blog.rodneyrehm.de/archives/14-Sorting-Were-Doing-
It-...](http://blog.rodneyrehm.de/archives/14-Sorting-Were-Doing-It-
Wrong.html) a couple of years ago wrote "While InsertionSort and MergeSort
(Apple and Mozilla) are stable, QuickSort (Google Chrome) is not (Issue 90).
Chrome will sort arrays using InsertionSort if the array has 10 or less
elements" and [http://stackoverflow.com/questions/234683/javascript-
array-s...](http://stackoverflow.com/questions/234683/javascript-array-sort-
implementation) agrees. [http://webreflection.blogspot.se/2009/04/internet-
explorer-a...](http://webreflection.blogspot.se/2009/04/internet-explorer-and-
its-inefficient.html) extends the comparison to IE and Opera, showing that
they are also n * log n implementations.

