I don't think the Bubble sort is good for any case except for ease of understanding of how it works.
Also Binary search requires a sorted list to work.
Bubble sor…. **QUIVERS UNCONTROLLABLY**
BRRRR!! I just can’t bring myself to even mention it, if we’re talking about usefulness!
Still, if I’m completely honest, like most programmers who *hate* its performance, I’ll have to admit to implementing it with very limited datasets just for its simplicity. I’ll stress here, for emphasis: VERY LIMITED DATASETS.
If I need to sort a deck of cards, then I might fall back onto a bubble sort. If it’s a grocery list, a bubble sort will do. If it’s my list of chores for the week, a bubble sort will do. Usually, any dataset with less than 100 elements in it can be bubble sorted.
Beyond that, I either grab a Binary Insertion Sort, a Quick Sort, or a simple Comb Sort routine and make use of them — for the following reasons:
When the data allows, nothing is faster than a Binary Insertion Sort. How does this work??
Start with an ordered list of ### items: apple, bat, cat, dog, frog, elephant…
Add a new item to the list: chicken
Do a binary search of your data to find the position where chicken goes: After 3rd word
Shift everything to the right one array element after that and insert the word in its proper place.
One shift of data in memory, coupled with a quick binary position search — it doesn’t get any faster or more efficent than this! (But, it’s a limited use case sort method.)
Method 2: Quick Sort — works to become the fastest sort method with just about any generalized data set. The only drawback here is if you recursively sort, I have seen issues with running out of stack space over the years. Generally, I’ll apply this for moderate sized data sets (say less than 1,000,000,000 data items).
Method 3: Comb Sort —almost as fast as quick sort and still very simple to implement with usually less than 20 lines of code. Works with all data sets, regardless of size, with no recursion or issues with stack limitations. If I’m going to take the trouble to copy/paste an existing sort into a different program, *this* is the one I fall back on. Comb Sort is also what MemSort is based upon, so if you’ve used it from the samples forums here, you’ve used a Comb Sort in your work before. ;)