more obvious tapemerge implementation
make-github-pseudonymous-again opened this issue · 2 comments
make-github-pseudonymous-again commented
use
while ( true ) {
if ( ai >= aj ) {
while ( bi < bj ) { ... }
return ;
}
if ( bi >= bj ) {
do { ... } while ( ai < aj ) ;
return ;
}
if ( compare( a[ai] , b[bi] ) <= 0 ) {
...
}
else {
...
}
++ci ;
}make-github-pseudonymous-again commented
make sure the new version keeps merge sort stable, i.e.
if ( compare( a[ai] , b[bi] ) === 0 ) {
c[ci] = a[ai] ;
...
}make-github-pseudonymous-again commented
migrated to comparison-sorting/merging#3