↕️ DSA

Sorting Algorithms Compared — Bubble to Quick Sort

📅 Jul 1, 2026 ⏱ 5 min read

Nobody writes sorts at work (arr.sort() exists) — but interviews use them to test if you understand complexity trade-offs.

The lineup

The merge step (what they actually ask you to write)

function merge(a, b) {
  const out = []; let i = 0, j = 0;
  while (i < a.length && j < b.length)
    out.push(a[i] <= b[j] ? a[i++] : b[j++]);
  return [...out, ...a.slice(i), ...b.slice(j)];
}

Questions that come up

Write the merge step on our judge.

← All Articles