In computer science and mathematics[?], a sort algorithm is an algorithm that puts elements of a list into order. Efficient sorting is important to optimizing the use of other algorithms (such as search algorithms and merge algorithms) that require sorted lists to work correctly; it is also often useful for canonicalizing[?] data and for producing humanreadable output.
Sort algorithms used in computer science are often classified by:
Sorting algorithms that are not stable can be specially implemented to be stable. One way of doing this is to artificially extend the key comparison, such that comparisons between two objects with otherwise equal keys are decided using the order of the entries in the original data order as a tiebreaker.
Some sorting algorithms follow with runtime order
(*) unstable
See workinplace article for the list of sort algorithms that can be written as workinplace.
An old version of QBASIC has a file "sortdemo.bas" in the examples folder that provides a graphical representation of several of the various sort procedures described here, as well as performance ratings of each.
Search Encyclopedia

Featured Article
