bub1.py 347 B

1234567891011121314151617181920
  1. def bubsort(l):
  2. #
  3. def fmin(ll):
  4. minv = ll[0]
  5. ind =0
  6. lr=len(ll)
  7. for x in range(1,lr):
  8. if ll[x]<minv:
  9. ind =x
  10. minv=ll[x]
  11. return ind
  12. #
  13. lc= l.copy()
  14. res= []
  15. while len(lc)>0:
  16. ind=fmin(lc)
  17. res.append(lc.pop(ind))
  18. return res