Sort Algorithm
There are many sort algorithm you can use. Which of them should you choose? The complexity show to you about the performance.
I put the main algorithm together to help to see the differences. More detail about all of them you can see in GeeksforGeeks.
Complexity
Based on this other post I separate some algorithms that we can see more frequently.
There is a work that compare all of these algorithm. On that post, you will see that algorithms like Insertion can have better results then Merge or Quick sort when you have not much data. However, if you have a several numbers of data the algorithms with better results will be Merge and Quick sort.
It's possible to see that QuickSort and MergeSort are very similar. However, the QuickSort is better if you pay attention to the space complexity O(log(n)). But the worst case the MergeSort have a better performance.
The Java's Arrays.sort() uses the QuickSort algorithm. It's used to sort primitive data. The QuickSort is not a stable algorithm and since you are working with primitive the stability is not an issue and the change of position does not make difference.
On other hands, Java's Collections.sort() uses MergeSort, a stable sort. This algorithm does not reorder equal elements. Since it's working with an object the stability is important.
Thinking about Heap vs Quick, both are not stable, but usually, QuickSort is faster than HeapSort. In the worst case, HeapSort is better than QuickSort. You will see in the test that the QuickSort result had been better when the quantity of the data was growing. More detail about this you can see here.
You also can see Why Quick Sort preferred for Arrays and Merge Sort for Linked Lists?.
Illustration
Conclusion
In practice we will not need to implement these algorithm. There are libraries that do this for us. But we need understand how this works to decide what to use.
Also, there are many posts explain each algorithm in detail. What I want with this post is put some of them together to have a general view. It makes my choice easier.