Sorting algorithms (JS)