[perf] use k-way merge instead of stable_sort when building the index of all lines