TPMMS (Two-Phase Multiway Merge Sort) — Interactive Visualizer

External Sorting • Teaching Aid

Controls

Phase: Run Generation
Pass: 1
I/O passes est: ≈ 2

About TPMMS

Two-Phase Multiway Merge Sort is the workhorse for sorting files that don’t fit in RAM. Phase 1 creates sorted runs that fit in memory. Phase 2 merges up to M−1 runs at a time (using 1 output buffer), possibly over multiple passes, until a single sorted file remains.

Tip: lower M to see multi-pass merging. Use Play or tap Next step.

Phase 1 — Run Generation
Disk — Input file
Memory (M pages)
Disk — Sorted runs
Merge (current pass)
Final output