Sorting algorithms/Bead sort: Difference between revisions

Line 2,210:
 
=={{header|Python}}==
#!/bin/python3
{{trans|Haskell}}
from itertools import zip_longest
<lang python>try:
 
from itertools import zip_longest
except:
try:
from itertools import izip_longest as zip_longest
except:
zip_longest = lambda *args: map(None, *args)
 
def beadsort(l):
return list(map(lensum, columns(columnszip_longest(*[[1] * e for e in l], fillvalue=0)))
 
def columns(l):
return [filter(None, x) for x in zip_longest(*l)]
 
# Demonstration code:
Anonymous user