this post was submitted on 01 Sep 2026
92 points (100.0% liked)
Programmer Humor
33288 readers
1004 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
- If the mod doesn't find it funny, you're banned. Ha-ha!... For real: do not use the community for "statements". There are other places for such content. Keep it chill and funny.
founded 3 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
As the addendum to the paper points out, this is more like insertion sort (with
iandjin a confusing order) than bubble sort. The actual "important" part of the algorithm happens whenj < i. (In fact, I'm quite certain there aren't even any swaps whenj >= iafter the first outer iteration.) (I think the page about people misremembering bubble sort is also worth looking at.)Honestly, I think this might actually be "better" than bubble sort, in the sense that at least it's incredibly easy to remember and not that hard to get correct. The only place where you could realistically mess up is confusing the relative order of
iandj-- and any amount of nontrivial testing will immediately show the error, since it reverses the sort order. I'd probably reach for this if I, for whatever insane reason, had to code up a sorting algorithm by hand for some task whereO(n^2)sorting was acceptable performance-wise. "Sort a list of 10 items in a very primitive programming language"-type deal.(Now that I say that, I'm kind of tempted to use it in some example program for my own in-development programming language, which currently doesn't have a builtin sort function...)