This is a JavaScript implementation of Dikstra's smoothsort. If the input is already sorted to some degree, it "smoothly" approaches O(n) running time. It is an in-place algorithm, and only requires O(1) auxiliary storage space.
The implementation is largely based on the Java code in the Wikipedia article.