mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-22 07:09:18 +02:00
fixing sort when less predicate is given without a key
This commit is contained in:
parent
efb6f24a61
commit
b71195955e
1 changed files with 12 additions and 4 deletions
|
@ -99,11 +99,19 @@ static sexp sexp_qsort_less (sexp ctx, sexp *vec,
|
|||
} else {
|
||||
mid = lo + (hi-lo)/2;
|
||||
swap(tmp, vec[mid], vec[hi]);
|
||||
sexp_car(args1) = tmp;
|
||||
b = sexp_apply(ctx, key, args1);
|
||||
if (sexp_truep(key)) {
|
||||
sexp_car(args1) = tmp;
|
||||
b = sexp_apply(ctx, key, args1);
|
||||
} else {
|
||||
b = tmp;
|
||||
}
|
||||
for (i=j=lo; i < hi; i++) {
|
||||
sexp_car(args1) = vec[i];
|
||||
a = sexp_apply(ctx, key, args1);
|
||||
if (sexp_truep(key)) {
|
||||
sexp_car(args1) = vec[i];
|
||||
a = sexp_apply(ctx, key, args1);
|
||||
} else {
|
||||
a = vec[i];
|
||||
}
|
||||
sexp_car(args2) = a;
|
||||
sexp_car(args1) = b;
|
||||
res = sexp_apply(ctx, less, args2);
|
||||
|
|
Loading…
Add table
Reference in a new issue