Merge algorithm code example