What is "Sorting"?

  • To arrange elements in an ordered sequence.
  • An algorithm that arrange the elements of a list in a certain order (either ascending or descending).
  • A Sorting Algorithm is used to rearrange a given array or list elements according to a comparison operator on the elements. The comparison operator is used to decide the new order of element in the respective data structure.(

Why is sorting important?

Sorted data is easier and more efficient to search.

The most common uses of sorted sequences are:

  • making lookup or search efficient;
  • making merging of sequences efficient.
  • enable processing of data in a defined order.

What is "Stability" in sorting algorithm?

A sorting algorithm is said to be stable if two objects with equal keys appear in the same order in sorted output as they appear in the input array to be sorted.