有一点niubiality的python min sorted code

  1 #!/usr/bin/env python
  2 #encoding=utf-8
  3 a=["zzzz","z","zzzzzzzzzzzzzzz"]
  4 def cmp(x,y):
  5   if x.__len__()>y.__len__():
  6     return 1
  7   elif x.__len__()==y.__len__():
  8     return 0
  9   else:
 10     return -1
 11
 12 a.sort(cmp)
 13 print a
 14 print min(a,key=lambda x:x.__len__())

原文地址:https://www.cnblogs.com/lexus/p/2795295.html