/i-cant-believe-it-sorts

The simplest (and most surprising) sorting algorithm ever?

Primary LanguagePython

i-cant-believe-it-sorts

This is the python implementation of a sorting algorithm by Stanley P. Y. Fung. It looks like it is wrong but it actually sorts.

From the paper:

    There is nothing good about this algorithm. It is slow – the algorithm
    obviously runs in Θ(n2) time, whether worst-case, average-case or best-case.
    It unnecessarily compares all pairs of positions, twice.
    It is not stable, does not work well for external sorting, cannot sort
    inputs arriving online, and does not benefit from partially sorted inputs.
    Its only appeal may be its simplicity, in terms of lines of code and the
    “symmetry” of the two loops.

I just found it quirky and wrote a python implementation for it. :)

References:

Stanley P. Y. Fung. Is this the simplest (and most surprising) sorting algorithm ever?, 2021.