Correct major mistake with 'sortArray' function