def f(n): final_n = [] for i in range(0,len(n)): max = n[i] for x in range(i,len(n)): if n[x]>max: index = x max=n[x] final_n.append(max) temp=n[index] n[index]=n[0] n[0]=temp print(n) print(final_n)a=[2,8,4,3,6]f(a)
Standard input is empty
[8, 2, 4, 3, 6] [6, 2, 4, 3, 8] [8, 2, 4, 3, 6] [6, 2, 4, 3, 8] [8, 2, 4, 3, 6] [8, 6, 8, 6, 8]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!