Welcome Guest, Not a member yet? Register   Sign In
Can anyone explain how this usort actually works
#5

usort is basically a 'merge sort' algorithm with guaranteed O(n log n) complexity, where n is the number of elements of an array. How it works is that it splits up the array into the smallest unit, so, 1 element of the array. Then it compares each element with the adjacent list, and merges the values. It is faster than bubble sort on large unsorted lists, but if the list is already sorted, bubble sort will be faster than merge sort.

Here is a good graphical representation on how it works, taken from wiki: https://upload.wikimedia.org/wikipedia/c...-300px.gif
Reply


Messages In This Thread
RE: Can anyone explain how this usort actually works - by slax0r - 09-28-2015, 04:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB