Joke Sort

By Susam Pal on 26 May 2021

Sleepsort in shell:

$ nums="5 1 3 6 2 4" sh -c 'for n in $nums; do sleep "$n" && echo "$n" & done; wait'
1
2
3
4
5
6

Bogosort in Python:

$ python3 -q
>>> import random
>>> nums = [5, 1, 3, 6, 2, 4]
>>> while nums != sorted(nums): random.shuffle(nums)
... 
>>> print(nums)
[1, 2, 3, 4, 5, 6]
>>>
Comments | #humour