我有這樣的列表:排序列表
['pt=media:song', 'c=100','class=song', 'object=mp3']
['class=text','pt=transaction:email','c=90','object=email']
['c=97','category=where','pt=text:where','class:question']
['object:mp4','class=movie', 'pt=media:movie','c=56']
我想對它們進行排序,使得我總是從'c='
開始字段出現第一,"pt="
出現第二和他們其餘的人按字母順序排序。
這樣的結果將是:
['c=100','pt=media:song','class=song', 'object=mp3']
['c=90','pt=transaction:email','class=text', 'object=email']
['c=97','pt=text:where','category=where','class:question']
['c=56','pt=media:movie','class=movie','object:mp4']
我怎麼去呢?
類似http://stackoverflow.com/a/21762295/538284的[在Python排序列表 –
可能重複的基礎在規則](http://stackoverflow.com/questions/21762177/sort-lists-in-python-based-on-a-rule) – Carpetsmoker