我需要的元組下面的列表中的Python排序:Python的排序問題
ListOfTuples = [('10', '2010 Jan 1;', 'Rapoport AM', 'Role of antiepileptic drugs as preventive agents for migraine', '20030417'), ('21', '2009 Nov;', 'Johannessen SI', 'Antiepilepticdrugs in epilepsy and other disorders--a population-based study of prescriptions', '19679449'),...]
我的目的是通過降序年(listOfTuples [2]),並通過升序作者(listOfTuples來訂購吧[2]):
sorted(result, key = lambda item: (item[1], item[2]))
但它不起作用。我如何獲得排序穩定性?
哪些是可能的日期格式?這裏我們看到「年/ monthabbr/day」和「year/monthabbr」。是否有可能只遇到「年」? – tokland 2010-07-24 15:41:49
是的,因爲數據格式不規則。 – 2010-07-26 08:23:49