Implementation of a few sorting algorithms in JavaScript