Sorting Networks

Initializing live version
Download to Desktop

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.

Starting from the left, a sorting network does a sequence of comparisons, interchanging elements if they are out of order. The network is set up so that by the time the data reaches the right-hand end, all the elements are sorted. Notice that better sorting networks tend to look more complex.

Contributed by: Stephen Wolfram (March 2011)
Open content licensed under CC BY-NC-SA



Not all types of sorting networks exist for every number of elements. Optimal networks are not yet known for more than 16 elements.

For less than 9 elements, there are no unique optimal sorting networks. Here the Batcher method achieves the minimal number of comparators for each case.

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.