Sorting Techniques
Sorting Techniques
Sorting Techniques
Sorting refers to arranging data in a particular format. Sorting algorithm specifies the way to arrange data in a particular order. Most
common orders are in numerical or lexicographical order.
The importance of sorting lies in the fact that data searching can be optimized to a very high level, if data is stored in a sorted
manner. Sorting is also used to represent data in more readable formats. Following are some of the examples of sorting in real-life
scenarios −
Telephone Directory − The telephone directory stores the telephone numbers of people sorted by their names, so that the
names can be searched easily.
Dictionary − The dictionary stores words in an alphabetical order so that searching of any word becomes easy.
https://www.tutorialspoint.com/data_structures_algorithms/sorting_algorithms.htm 1/3
7/30/2021 Data Structure - Sorting Techniques - Tutorialspoint
If a sorting algorithm, after sorting the contents, changes the sequence of similar content in which they appear, it is called unstable
sorting.
Stability of an algorithm matters when we wish to maintain the sequence of original elements, like in a tuple for example.
https://www.tutorialspoint.com/data_structures_algorithms/sorting_algorithms.htm 2/3
7/30/2021 Data Structure - Sorting Techniques - Tutorialspoint
Important Terms
Some terms are generally coined while discussing sorting techniques, here is a brief introduction to them −
Increasing Order
A sequence of values is said to be in increasing order, if the successive element is greater than the previous one. For example, 1,
3, 4, 6, 8, 9 are in increasing order, as every next element is greater than the previous element.
Decreasing Order
A sequence of values is said to be in decreasing order, if the successive element is less than the current one. For example, 9, 8, 6,
4, 3, 1 are in decreasing order, as every next element is less than the previous element.
Non-Increasing Order
A sequence of values is said to be in non-increasing order, if the successive element is less than or equal to its previous element in
the sequence. This order occurs when the sequence contains duplicate values. For example, 9, 8, 6, 3, 3, 1 are in non-increasing
order, as every next element is less than or equal to (in case of 3) but not greater than any previous element.
Non-Decreasing Order
A sequence of values is said to be in non-decreasing order, if the successive element is greater than or equal to its previous
element in the sequence. This order occurs when the sequence contains duplicate values. For example, 1, 3, 3, 6, 8, 9 are in non-
decreasing order, as every next element is greater than or equal to (in case of 3) but not less than the previous one.
https://www.tutorialspoint.com/data_structures_algorithms/sorting_algorithms.htm 3/3