import random a = [] for i in range(10): a.append(random.randrange(10)) print "We start from this random list:", a result = [] while a: m = min(a) result.append(m) a.remove(m) print "Sorted, the list looks like this:", result