PHP Sort Algorithms
A play to implement some sorting algorithms PHP.
Not built for speed. Built to understand functionality. You would better off using internal sorting algorithms for speed.
Quick Sort
Quick sort is usually an effective sorting algorithm. This implementation is about 80% slower than the default sort() function within PHP.
Wikipedia also mentions that this is a “naive implementation“. Taking the first element in the array can be a low number (if we’d already sorted some of the array), and therefore bring us close to O(n2)… which is bad.
Photo by Aleks Dahlberg on Unsplash
Sorry, the comment form is closed at this time.