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.
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.