Replaced my crappy bubble sort with Javascript's native array sort method.