added ability to change the sorting algorithm on the fly