sorting algorithms in javascript