JavaScript sorting and other goodies