Sorting algorithms in PHP