I wrote this script some time ago to test a few sorting routines in JavaScript. Recently I was studying sorting again and thought it would be fun to show graphically how these routines "swap" data. I had to include a delay, because on modern computers is was simply too fast :) JavaScript has no "sleep" or "wait" command, so I had to use a famous trick to have the sort routine recursively call itself.

These are the three sorting algorithms I implemented:

selection sort / bubble sort / quick sort

Check out the code here.