How to sort your socks using Javascript
summary
Explains that JavaScript engines implement different sorts (SpiderMonkey uses merge sort, V8 and Chakra use quicksort), shows tiny JavaScript implementations of insertion/merge/quick (10–31 lines) and benchmarks run on a Mac in Chrome: insertion sort wins for 10–1,000 elements, quicksort overtakes native and stays fastest up to millions (one million crash noted, ten million tested), and stresses stability matters for preserving prior order and that self-hosted JS engine code plus context-switch overhead can make well-written JS sorts faster than native.
AI-written summary · about
chapters (9)
- 0:00Intro
- 0:36Context
- 2:16Computational Complexity
- 17:45Design strategies
- 18:45Divide Conquer
- 20:08Quicksort
- 21:14Performance
- 23:23Benchmark
- 25:53Conclusion
related talks
23mHow to Sort Your Socks Using JavaScript
24mCS101 Intro to Computational Complexity: The Sorting Problem
34mJavaScript is an Oddball
39mHow much performance can you get out of Javascript?
46mHow much performance can you get out of JavaScript?
57mDown the Rabbit Hole: JavaScript in Wonderland
29mExtreme JavaScript Performance
31mJavaScript Compilation Techniques or "Wasn't JavaScript supposed to be slow?"
