def medianSort(a, b, c, d, e):
if a > b: a, b = b, a
if d > e: d, e = e, d
if a < d:
if b > c: b, c = c, b
else:
a, d = d, a
b, d = d, b
if c > e: c, e = e, c
c, d = d, c
if b > d:
b, d = d, b
c, e = e, c
if c > d: c, d = d, c
return [a, b, c, d, e]
arr = [1, 2, 3, 4, 5]
from random import shuffle
for i in range(0, 1000):
shuffle(arr)
tmp = medianSort(arr[0], arr[1], arr[2], arr[3], arr[4])
assert(tmp[0] < tmp[2] and tmp[1] < tmp[2] and tmp[2] < tmp[3] and tmp[2] < tmp[4])