14 votes

The vindication of bubble sort

3 comments

  1. ignorabimus
    Link
    Excerpts

    Excerpts

    So I thought I was on firm ground, stating there are no use cases for bubble sort. However, a few years ago a friend of mine pointed out they had found one.

    The case was that a sequence was supposed to be sorted, but it wasn’t critical if it wasn’t. I.e. the more well-sorted the sequence was, the better, but everything would work okay-ish even with a random order.
    ...
    The central part of the bubble sort is stateless and idempotent on a sorted sequence, but on an unsorted sequence it will always decrease its entropy. It gets even better when, as in this case, the application needs to regularly interate the sequence anyway. It could swap adjacent pairs as part of that iteration, at very little additional cost because the cache lines are already hot.

    9 votes
  2. [2]
    Bwerf
    Link
    I'm fairly certain that is not correct (it's 2024-11-26 in the article, so a slightly different wrong)

    Published Nov 25 2024

    I'm fairly certain that is not correct (it's 2024-11-26 in the article, so a slightly different wrong)

    4 votes
    1. widedub
      Link Parent
      Perhaps he provided several "published on" dates and is using a bubble sort to eventually get the right order

      Perhaps he provided several "published on" dates and is using a bubble sort to eventually get the right order

      7 votes