Introduction to Sorting and Sorting Algorithms


Introduction to Sorting and Sorting Algorithms

In this article, we are going to talk about the intro to sorting algorithms. sorting as a concept is very deep. It has a lot of things that we do. it's quite often that we like to arrange things or data in a certain order. sometimes to improve the readability of that data or at others to search some information quickly out of the data.

For example, let us take an example of a card game. We are playing a card game, even though the number of cards is very less but we like to keep that card sorted by rank.

Let's take one more example to understand the concept when we go to a shopping site to shop for something then the site gives options to sort products by price (high-low), ratings given by the user.

Sorting is a helpful feature here and there are so many places where we like to keep our data sorted. It can be our library to keep our books sorted or a language dictionary where we want to keep words sorted so that searching a word in the dictionary is easy or fast.

Now it's time to define sorting formally,


Sorting is a technique of arranging the elements in a list or collection in increasing or decreasing order of some property. The list should be homogenous to that means all the elements should be of the same data type. (To study sorting algorithms most of the time we use a list of integers)

For example:

4, 1, 6, 5, 9  

1, 4, 5, 6, 9      (sorting in increasing order)

9, 6, 5, 4, 1      (sorting in decreasing order)

As we have said in the definition, we can sort on any property. What if we want to sort this list based on let's say, an increasing number of factors yes, we can do that too.

Complex type examples of sorting:

 hotel sorting by price 

 online shopping sites for product sorting (by price, brand, color, etc...)

General Definition of sorting algorithms:

In computer science, a sorting algorithm is an algorithm that puts elements of a list in a certain order. The most frequently used orders are numerical order and lexicographical order.

Some of the sorting algorithms that are mostly used are:

  • Bubble sort

  • Selection sort

  • Merge sort

  • Quick sort

  • Heap sort

  • Radix sort

  • Insertion sort

  • Counting sort

Classification of sorting algorithms

1) Time Complexity  

2) Space Complexity

  • In place, constant memory
  • memory usage grows with input size

3) Stability 

4) Internal sort or External Sort 

5) Recursive or Non-recursive 


The above Article is contributed by kunal Bandale. To contribute an article just click here  


Post a Comment

If you have any query, please let us know