Implementation of different sort algorithms in javascript