from random import random, seed def check(tag, ys): from time import perf_counter as now start = now() ys.sort() finish = now() elapsed = finish - start print(f"{tag:9s} {elapsed:6.2f}") first = ys[0] for i in range(1, len(ys)): second = ys[i] if second < first: raise ValueError(second, "at", i, "<", first) first = second ys.clear() return elapsed length = 10000000 seed(1234567891) xs = [random() for _ in range(length)] check("float", xs[:]) check("(float,)", [(x,) for x in xs]) check("[float]", [[x] for x in xs])