In [16]: L=['abc','ABD','aBe']

    In [17]: L.sort()

    In [18]: L
    Out[18]: ['ABD', 'aBe', 'abc']

    In [19]: L=['abc','ABD','aBe']

    In [20]: L.sort(key=str.lower)

    In [21]: L
    Out[21]: ['abc', 'ABD', 'aBe']

    In [22]: L.sort(key=str.lower,reverse=True)

    In [23]: L
    Out[23]: ['aBe', 'ABD', 'abc']

     
    In [24]: L=['abc','ABD','aBe']
     
    #用built-in函数sorted进行排序
    In [25]: sorted(L,key=str.lower,reverse=True)
    Out[25]: ['aBe', 'ABD', 'abc']
     
    #L本身顺序没变
    In [26]: L
    Out[26]: ['abc', 'ABD', 'aBe']

    In [28]: sorted([x.lower() for x in L],reverse=True)
    Out[28]: ['abe', 'abd', 'abc']

    In [29]: L
    Out[29]: ['abc', 'ABD', 'aBe']
     
    In [30]: D={'a':1,'c':3,'b':2}

    In [31]: D.has_key('c')
    Out[31]: True

    In [32]: 'c' in D
     
    In [33]: T=('cc','aa','dd','bb')

    In [34]: sorted(T)
    Out[34]: ['aa', 'bb', 'cc', 'dd']

    In [35]: T
    Out[35]: ('cc', 'aa', 'dd', 'bb')

    In [36]: tmp=list(T)

    In [37]: tmp.sort
    Out[37]: <function sort>

    In [38]: tmp.sort()

    In [39]: T
    Out[39]: ('cc', 'aa', 'dd', 'bb')

    In [40]: tmp
    Out[40]: ['aa', 'bb', 'cc', 'dd']

    In [41]: T=tuple(tmp)

    In [42]: T
    Out[42]: ('aa', 'bb', 'cc', 'dd')
     
    #list中的字典对象排序
    In [43]: L=[{"dt": "20130503000800 ", "baidu_total": 414100, "dl": 52, "realname"
    : "zhuangyan"},{ "dt": "20130503001000 ", "baidu_total": 414190, "dl": 54, "real
    name": "liyan"},{ "dt": "20130504000800 ", "baidu_total": 414190, "dl": 60, "rea
    lname": "wangyi"}]
     

    In [44]: L.sort(key=lambda x:(-x["baidu_total"],-x["dl"],x["dt"]))

    In [45]: L
    Out[45]:
    [{'baidu_total': 414190,
      'dl': 60,
      'dt': '20130504000800 ',
      'realname': 'wangyi'},
    {'baidu_total': 414190,
      'dl': 54,
      'dt': '20130503001000 ',
      'realname': 'liyan'},
    {'baidu_total': 414100,
      'dl': 52,
      'dt': '20130503000800 ',
      'realname': 'zhuangyan'}]