import random def Q(A): if len(A)<2: return A p = A[0] return Q(filter(lambda x: x<p, A)) + \ filter(lambda x: x==p, A) + \ Q(filter(lambda x: x>p, A)) A = [random.randint(0, 100) for x in range(12)]print (A)print (Q(A))
Standard input is empty
[12, 8, 20, 1, 80, 49, 53, 14, 8, 47, 35, 96] [1, 8, 8, 12, 14, 20, 35, 47, 49, 53, 80, 96]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!