fix quicksort implementation

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35580 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2012-09-20 10:19:18 +00:00
parent a4140c8f51
commit 7f177becc5
2 changed files with 11 additions and 5 deletions

View file

@ -1,3 +1,7 @@
2012-09-20 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSQuickSort.m: Fixed this to compile and (apparently) work.
2012-09-20 Richard Frith-Macdonald <rfm@gnu.org>
* configure.ac: Change sort selection to use shellsort by default and

View file

@ -62,7 +62,7 @@ _GSQuickSort(id *objects,
while (left < right)
{
if (GSCompareUsingDescriptorOrComparator(left, right,
if (GSCompareUsingDescriptorOrComparator(objects[left], pivot,
comparisonEntity, type, context) == NSOrderedDescending)
{
SwapObjects(&objects[left], &objects[--right]);
@ -74,10 +74,12 @@ _GSQuickSort(id *objects,
}
SwapObjects(&objects[--left], &objects[sortRange.location]);
SortObjectsWithDescriptor(objects, NSMakeRange(sortRange.location, left
- sortRange.location), sortDescriptor);
SortObjectsWithDescriptor(objects, NSMakeRange(right,
NSMaxRange(sortRange) - right), sortDescriptor);
_GSQuickSort(objects,
NSMakeRange(sortRange.location, left - sortRange.location),
comparisonEntity, type, context);
_GSQuickSort(objects,
NSMakeRange(right, NSMaxRange(sortRange) - right),
comparisonEntity, type, context);
}
}