Comparison Sort

A comparison sort is a type of sorting algorithm that only reads the list elements through a single abstract comparison operation (often a "less than or equal to" operator) that determines which of two elements should occur first in the final sorted list. The only requirement is that the operator obey two of the properties of a total order:

  1. if ab and bc then ac (transitivity)
  2. for all a and b, either ab or ba (totalness or trichotomy).

It is possible that both ab and ba; in this case either may come first in the sorted list. In a stable sort, the input order determines the sorted order in this case.

A metaphor for thinking about comparison sorts is that someone has a set of unlabelled weights and a balance scale. Their goal is to line up the weights in order by their weight without any information except that obtained by placing two weights on the scale and seeing which one is heavier (or if they weigh the same).

Read more about Comparison Sort:  Examples, Performance Limits and Advantages of Different Sorting Techniques, Number of Comparisons Required To Sort A List

Famous quotes containing the words comparison and/or sort:

    When we reflect on our past sentiments and affections, our thought is a faithful mirror, and copies its objects truly; but the colours which it employs are faint and dull, in comparison of those in which our original perceptions were clothed.
    David Hume (1711–1776)

    Most Americans are born drunk, and really require a little wine or beer to sober them. They have a sort of permanent intoxication from within, a sort of invisible champagne.... Americans do not need to drink to inspire them to do anything, though they do sometimes, I think, need a little for the deeper and more delicate purpose of teaching them how to do nothing.
    Gilbert Keith Chesterton (1874–1936)