Welcome Guest, Not a member yet?
 Can anyone explain how this usort actually works slax0r/dev/null Posts: 57 Threads: 1 Joined: Nov 2014 Reputation: 09-28-2015, 04:22 AM 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 Website: http://tomaz.lovrec.eu GitHub: https://github.com/slax0rr Twitter: https://twitter.com/slax0rr .pborder { border-top: 1px dashed #ccc; padding-bottom: 10px; margin: 15px; }

 Messages In This Thread Can anyone explain how this usort actually works - by PaulD - 09-27-2015, 05:30 PM RE: Can anyone explain how this usort actually works - by slax0r - 09-28-2015, 12:20 AM RE: Can anyone explain how this usort actually works - by Narf - 09-28-2015, 02:38 AM RE: Can anyone explain how this usort actually works - by PaulD - 09-28-2015, 03:24 AM RE: Can anyone explain how this usort actually works - by slax0r - 09-28-2015, 04:22 AM RE: Can anyone explain how this usort actually works - by PaulD - 09-28-2015, 04:42 AM RE: Can anyone explain how this usort actually works - by slax0r - 09-28-2015, 04:52 AM RE: Can anyone explain how this usort actually works - by PaulD - 09-28-2015, 05:22 AM RE: Can anyone explain how this usort actually works - by ignitedcms - 10-01-2015, 12:09 PM RE: Can anyone explain how this usort actually works - by PaulD - 11-09-2015, 08:15 AM