【发布时间】:2018-10-15 16:32:47
【问题描述】:
我下面有字典
{0: {'STATE': 'AL', '人口':'151449859682', 'TOP_CITY': '1', '排名':'1'}, 1:{'状态':'纽约', '人口':'8955557', 'TOP_CITY': '6', '排名':'2'}, 2:{'状态':'CA', “人口”:“7123215”, 'TOP_CITY': '10', '排名':'3'}, 3:{'状态':'PH', '人口':'68557813', 'TOP_CITY': '11', '排名':'4'}, 4:{'状态':'IN', '人口':'7678676', 'TOP_CITY': '14', '排名':'5'}}
我想通过从用户输入中询问,按照 RANK 降序排序
value2sort= input('Enter the value to sort')
排名
parameter= input('asc for ascending order and desc for descending order')
描述
预期低于
{4: {'STATE': 'IN', '人口':'7678676', 'TOP_CITY': '14', '排名':'5'}, 3:{'状态':'PH', '人口':'68557813', 'TOP_CITY': '11', '排名':'4'}, 2:{'状态':'CA', “人口”:“7123215”, 'TOP_CITY': '10', '排名':'3'}, 1:{'状态':'纽约', '人口':'8955557', 'TOP_CITY': '6', '排名':'2'}, 0:{'状态':'AL', '人口':'151449859682', 'TOP_CITY': '1', '排名':'1'}}
【问题讨论】:
-
字典未排序
标签: python dictionary collections enumeration