logoalt Hacker News

whizzter • today at 10:18 AM • 1 reply • view on HN

Technically the first pass will ensure that the smallest element ends up at position 0 even if it's looked at more times.

Bubblesort really is a family of "this is something I figured out myself that runs by looping in O(N^2) by moving things to the front/back"


Replies

pcthrowaway • today at 10:49 AM

> Technically the first pass will ensure that the smallest element ends up at position 0 even if it's looked at more times

Read it again; First pass ensures that the largest element ends up in position 0. Yet it somehow manages to sort ascending by the end.

It's not very intuitive and it's probably the least efficient sorting algorithm I've seen besides sleepsort[1]

[1]: https://www.reddit.com/r/programminghorror/comments/lgsd18/i...