Get job ready skill with Career Paths     |       Start learning for free!

Cart icon
User menu icon
User icon
Lightbulb icon
How it works?
FAQ icon
Contact icon
Terms of service icon
Terms of service
Privacy policy icon
Privacy Policy
Zdjęcie główne artykułu.

Sorting algorithms - what you need to know

Sorting is one of the most important things in programming. Take a look at the applications or services you use. Surely you can easily spot a list with sorted data.

  • To-do list.
  • A list of orders you've placed in an online store.
  • A list of expenses sorted from largest to smallest.

You could find dozens of examples like this. Simply put, wherever you look there is data that is sorted in some way. We like to operate on organized data. It is easier and more convenient. Think what would happen if you had to review hundreds of items on the list, that are arranged in a completely random way.

How the sorting is performed

To sort the data we need some kind of algorithm, which performs the sorting. Such an algorithm can be reduced to a simple diagram:

unsorted input data -> algorithm -> sorted output data.

So we take the data, which is put in a random order, process it with the appropriate algorithm and at the output we get sorted data. And that's the whole idea.

Various sorting algorithms

There are all kinds of sorting algorithms:

  • Bubble sorting;
  • Insertion sorting;
  • Comb sorting;
  • Sorting by counting;
  • Selection sorting;

This is just the tip of the iceberg because there are quite a few such algorithms. These algorithms differ from each other in various characteristics. Some are faster and others are slower. Some are simpler to implement and others are more complex. Some of them have practical applications and others are more "academic".

What you have to know

This is a good question. In fact, in many programming languages we have some data structures that can be sorted using built-in mechanisms. This means only that you can use ready-made algorithms to sort such data. However, it is good to know what will happen when you use a specific sorting method. This way you can evaluate the complexity, execution time, and precision of your chosen method. It is a good idea to master at least the basic sorting algorithms. The point is to have some reasonable understanding of the subject. And to be aware what the consequences of sorting data in a suboptimal way may be.

Job interview questions

Are you going to apply for a job as a software developer? Then prepare yourself in sorting algorithms. This is one of the favorite topics of recruiters in IT. There is a good chance that at the job interview you will be tasked with implementing or explaining a particular sorting algorithm. Some say that this is a very academic approach to the topic because in practice such algorithms are rarely written from scratch. Nevertheless, such questions often appear so do not be surprised.

In conclusion

Sorting algorithms are very important because thanks to them we can work with organized data. In practice, such algorithms are rarely written from scratch because sorting is a problem often implemented using built-in language mechanisms, ready-made functions, programming libraries, etc. If you are serious about programming you will need a good grasp of such algorithms. If only to evaluate the computational complexity of an algorithm. And also not to be surprised when applying for a job.