The data is displayed as:
rows=[{' date ': ' 2018-09-04 ', ' Test 1 ': ' 50.00 ', ' Test 2 ': ' 100% '}, {' Date ': ' 2018-09-05 ', ' Test 1 ': ' 100% ', ' Test 2 ': ' No Execute '}, {' Date ': ' 2018-09-06 ', ' Test 1 ': ' 100% ', ' Test 2 ': ' 100% '}, {' Date ': ' 2018-08-31 ', ' Test 1 ': ' No execution ', ' Test 2 ': ' No Execution '}, {' Date ': ' 2018-09-01 ', ' Test 1 ': ' No execution ', ' Test 2 ': ' No Execute '}, {' Date ': ' 2018-09-02 ', ' Test 1 ': ' No execution ', ' Test 2 ': ' No Execute '}, {' Date ': ' 2018-09-03 ', ' Test 1 ': ' No execution ', ' Test 2 ' : ' No execution '}]
Rows is a dictionary type of data in a list,list, sorting the date from small to large, using the sort of list
1. Use the Sort method
def function (date): print (date[' Date ')) return date[' Date ']rows.sort (key=function) print (rows)
2. Using sorted
Sorted (rows,key=lambda keys:keys[' Date ')
Python to sort dictionaries in a list