fork download
  1. l =[1,4,7,9,1,3,5,10,11]
  2. l.sort() # sort the array
  3. s=[]
  4. for i in range(len(l)//2):
  5. s.append(l[i]) # append some small value
  6. s.append(l[-i -1]) # append some large value
  7. if len(l)%2:
  8. s.append(l[len(l)//2]) # for array with odd length
  9. print(s)
  10.  
  11.  
  12. # your code goes here
Success #stdin #stdout 0.02s 27640KB
stdin
Standard input is empty
stdout
[1, 11, 1, 10, 3, 9, 4, 7, 5]