possibly do the correct comparison I hope

This commit is contained in:
jacekpoz 2024-04-10 13:03:34 +02:00
parent 95fc5a1e1d
commit b8ec6963be
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -41,6 +41,22 @@ fn dual_pivot_partition(list: &mut [u64], res: &mut SortResult) -> (usize, usize
let q = list[list.len() - 1]; let q = list[list.len() - 1];
while k <= g { while k <= g {
if ((list.len() - 1) - g) > (l - 1) {
if compare(list[k], q, &mut comps) != LESS {
while compare(list[g], q, &mut comps) == GREATER && k < g {
g -= 1;
}
swap(list, k, g, &mut swaps);
g -= 1;
if compare(list[k], p, &mut comps) == LESS {
swap(list, k, l, &mut swaps);
l += 1;
}
} else if compare(list[k], p, &mut comps) == LESS {
swap(list, k, l, &mut swaps);
l += 1;
}
} else {
if compare(list[k], p, &mut comps) == LESS { if compare(list[k], p, &mut comps) == LESS {
swap(list, k, l, &mut swaps); swap(list, k, l, &mut swaps);
l += 1; l += 1;
@ -55,6 +71,7 @@ fn dual_pivot_partition(list: &mut [u64], res: &mut SortResult) -> (usize, usize
l += 1; l += 1;
} }
} }
}
k += 1; k += 1;
} }