[Python-ideas] Disallow orderring comparison to NaN

Mike Graham mikegraham at gmail.com
Thu Apr 28 16:22:54 CEST 2011


On Thu, Apr 28, 2011 at 10:01 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> I think I would like to see a demonstration of this rather than just take
> your word for it.

One demonstration would be

def bubble_sort(xs):
    while True:
        changed = False
        for i in range(len(xs) - 1):
            if not (xs[i] < xs[i + 1]):
                changed = True
                xs[i], xs[i + 1] = xs[i + 1], xs[i]
        if not changed:
            break

bubble_sort([float('nan)'] * 2)



More information about the Python-ideas mailing list