Fixed the merging order of FinnSort

This commit is contained in:
finnm 2024-12-17 13:24:50 +01:00
parent b1f94636c7
commit 59bfd44f45

View File

@ -28,7 +28,7 @@ public class FinnSort {
int p = power(runs.getLast(), new Run(i, j, 0), n);
while (runs.size() >= 2 && p < power(runs.getLast(), runs.get(runs.size() - 2), n)) {
basicMerge(a, runs.removeFirst(), runs.removeFirst(), c);
basicMerge(a, runs.removeLast(), runs.removeLast(), c);
}
runs.add(new Run(i, j, p));