I have a certain list and I need to sort it.
[{'inventory_id': 25,
'location_id': 12,
'package_id': False,
'partner_id': False,
'prod_lot_id': False,
'product_id': 7,
'product_qty': 0,
'product_uom_id': 1,
'sequence': '10',
'theoretical_qty': 10.0},
{'inventory_id': 25,
'location_id': 12,
'package_id': False,
'partner_id': False,
'prod_lot_id': False,
'product_id': 8,
'product_qty': 0,
'product_uom_id': 1,
'sequence': '3',
'theoretical_qty': 15.0},
{'inventory_id': 27,
'location_id': 12,
'package_id': False,
'partner_id': False,
'prod_lot_id': False,
'product_id': 9,
'product_qty': 0,
'product_uom_id': 1,
'sequence': '7',
'theoretical_qty': 21.0}]
I need to sort these 3 records on the basis of 'sequence'
key field.
After the sorting the list output should be:
[{'inventory_id': 25,
'location_id': 12,
'package_id': False,
'partner_id': False,
'prod_lot_id': False,
'product_id': 8,
'product_qty': 0,
'product_uom_id': 1,
'sequence': '3',
'theoretical_qty': 15.0},
{'inventory_id': 27,
'location_id': 12,
'package_id': False,
'partner_id': False,
'prod_lot_id': False,
'product_id': 9,
'product_qty': 0,
'product_uom_id': 1,
'sequence': '7',
'theoretical_qty': 21.0},
{'inventory_id': 25,
'location_id': 12,
'package_id': False,
'partner_id': False,
'prod_lot_id': False,
'product_id': 7,
'product_qty': 0,
'product_uom_id': 1,
'sequence': '10',
'theoretical_qty': 10.0}]
The no of records can be variable and will be dynamic Right now they are three records but they can be more than 10 as well.