I was trying to sort a list whose element is dictionary. I want to sort my list by the key Route
.
Here I did:
MenuList = [
{
'Title': [
{'Description': 'Form Customer Center'},
{'Route': 'LoanCentre'},
{ 'Menu': [
{'Parent': 'Customer'},
{'Order': 4}
]}
]
},
{
'Title': [
{'Description': 'Customer'},
{'Route': 'CustomerCenter'},
{ 'Menu': [
{'Parent': 'Customer'},
{'Order': 3}
]}
]
}
]
print (MenuList.sort())
TypeError: '<' not supported between instances of 'dict' and 'dict'>
Any thought to sort this kind of list please?
I just want to get result of this:
MenuList = [
{
'Title': [
{'Description': 'Customer'},
{'Route': 'CustomerCenter'},
{ 'Menu': [
{'Parent': 'Customer'},
{'Order': 3}
]}
]
},
{
'Title': [
{'Description': 'Form Customer Center'},
{'Route': 'LoanCentre'},
{ 'Menu': [
{'Parent': 'Customer'},
{'Order': 4}
]}
]
}
]