Did you know? · Science & Medicine

John von Neumann invented merge sort in 1945

In 1945 John von Neumann invented merge sort, one of the most widely used methods for putting data in order, in what Donald Knuth called his first computer program.

John von Neumann
John von Neumann · 1903–1957
Person
John von Neumann
Lived
1903–1957
Field
Mathematics & computing
From
Hungarian-American

The story

Sorting, putting a list of items in order, is one of the most common tasks a computer performs. Doing it efficiently matters enormously when the list holds millions of records, and how a machine would handle sorting was one of the questions John von Neumann considered when estimating how much memory a computer would need.

In 1945, while thinking about how the planned EDVAC computer would be used, John von Neumann devised a method now called merge sort. The idea is elegant: split the list in half, sort each half, then merge the two sorted halves into one by repeatedly taking the smaller of the two front items. Applied over and over, the method sorts any list in a number of steps that grows only modestly as the list gets longer.

He wrote out by hand a program for the merging step, a 23-page manuscript that his colleague Herman Goldstine kept among his papers. In 1970 the computer scientist Donald Knuth published a study of it titled Von Neumann's First Computer Program, examining the insights it contained, suggesting improvements and pointing out a bug. A detailed description and analysis of a bottom-up version of merge sort appeared in a report by Goldstine and von Neumann in 1948.

Merge sort has several useful properties. It is stable, meaning that items with equal keys keep their original order, and it works well on data that can only be read in sequence, which made it ideal for tapes and linked lists. It can also be split across many processors.

Merge sort remains a staple of computer science courses and of real software. It has been Perl's default sorting method since version 5.8, Java uses it for sorting objects, and the Linux kernel uses it for linked lists. Timsort, a hybrid of merge sort and insertion sort, is used by Python and by the Java and Android platforms.

Why it matters

Merge sort helps computers everywhere organise data quickly, from databases to search results.

About John von Neumann

Budapest-born mathematician whose 1945 EDVAC report set out the stored-program design behind almost every computer, and who helped found game theory and modern quantum mechanics.

Read the full profile
John von Neumann
1903–1957 · Mathematics & computing
View profile →

More about John von Neumann

Sources

Another act of tikkun olam. This is part of tikkun olam, the Jewish idea of repairing the world, and every one of us can add to it.

More in Science & Medicine

On kindness & the treatment of others
“A friend is devoted at all times; a brother is born to share adversity.”
Proverbs 17:17