PYTHON Programing:http://www.tutorialspoint.com/python/dictionary_items.htm
Description
The method items() returns a list of dict's (key, value) tuple pairs
Syntax
Following is the syntax for items() method:
dict.items()
Return Value
This method returns a list of tuple pairs.
Example
The following example shows the usage of items() method.
#!/usr/bin/python
dict = {'Name': 'Zara', 'Age': 7}
print "Value : %s" % dict.items()
# after running:
Value : [('Age', 7), ('Name', 'Zara')]
对字典按键排序,用元组列表的形式返回,同时使用lambda函数来进行:
sorted(dict.items(), key=lambda dict:dict[0])
返回值:[('Age', 7), ('Name', 'Zara')]