My recollection of sorting an insert is that you get new records one at a time, so if you already have data to sort, you will need twice as much data β one for reading, one for writing. For any nontrivial dataset, this is likely to cost more memory than the sorting algorithm. Bubbles can be sorted in place (i.e. if you already have a block of data to sort, enough extra memory is needed to store one record or even one byte.
Sorting bubbles will also require less code to write.
Since there is always a trade-off between speed and memory (or, indeed, any two resources), this is not always the case. However, if Method A is faster and simpler and uses less memory than Method B, then B is really not suitable for competition.
source share