I am merging files for an index, I worked around a hack to allow logarithmic merging without any heap structures just by clever tracking of numbers.
I'd have the in-memory index construction worked out, and the merging of 2 sub-indexes also works nicely, this is the last step in getting it to work, i'd like to have merging of the old indexes going on while new indexes are made. I can also try adding this code to the separate merging file, calling itself recursively or iteratively.