Sorting Algorithms in JavaScript