PHP Classes

I've only used heap sort and quick sort for this so far.

Recommend this page to a friend!

      PHP Sort Class  >  All threads  >  I've only used heap sort and quick...  >  (Un) Subscribe thread alerts  
Subject:I've only used heap sort and quick...
Summary:Package rating comment
Messages:1
Author:Scott Matthews
Date:2008-10-22 11:56:17
 

Scott Matthews rated this package as follows:

Utility: Good
Consistency: Good
Documentation: Sufficient
Examples: Good

  1. I've only used heap sort and quick...   Reply   Report abuse  
Picture of Scott Matthews Scott Matthews - 2008-10-22 11:56:17
I've only used heap sort and quick sort for this so far. I was really happy to find someone else had implemented this because I needed a more efficient sort approach than usort.

My main issue was that there is a bug in quick sort if the length of the array is less than 3. For large arrays, there is the potential for that block of implementation (if(!isset($arr[2]))) to return values that are not sorted. I added a check in it to swap the values if they are not in the order desired.

Also, it would be good to have an option for these to be ascending or descending. I've re-implemented them as quicksort_descending for my purpose since I didn't want the extra conditional check to slow the processing down.