fixes sorting algorithms