Write Python code to demonstrate sort a list of dictionary where value date is in string


Topic: Write Python code to demonstrate sort a list of dictionary where value date is in string

Solution

ini_list = [{'name':'akash', 'd.o.b':'1997-03-02'}, 
            {'name':'manjeet', 'd.o.b':'1997-01-04'}, 
            {'name':'nikhil', 'd.o.b':'1997-09-13'}] 
print ("initial list : ", str(ini_list)) 
ini_list.sort(key = lambda x:x['d.o.b']) 
print ("result", str(ini_list)) 



List all Python Programs