There are a number of sorting algorithms you can use in your programs. How can you know which one is the best? There is really no clear answer to be honest. The bottom line is that you have to take into account what your program will be sorting. Will the data be completely mixed and random? Will the data be nearly sorted? Will you be sorting HUGE data sets, or small data sets? All of these factors plus more will play a role into choosing the most efficient algorithm for your program. Here is a website that compares the run time of 8 different algorithms on 4 different initial conditions. You can watch and see how much time it takes each data set to be sorted and compare them. You can even change the problem size to see the effects of larger and smaller data sets. It is such a good visual representation of how these algorithms work. Here is the link:
https://www.toptal.com/developers/sorting-algorithms
I did a tutorial on bubble sort a while ago. This is a very easy algorithm to learn. I wanted to explain it because my tutorial series has been very beginner-based and as simplified as I could make it. The bubble sort is perfectly fine with small data sets, but when you get to HUGE databases it is one of the absolute worst algorithms you can choose! It would take an eternity compared to some of the other sort algorithms!
I just found a gif someone made of this website!
Image source