[Solved] Sorting a python list based on date? [closed]


try, and you will get you expect sort

In [51]: a=[['xX0001', '10006', '102', '', '2018-02-02', 3233.9, 0.0, 36816.18, ''], 
    ...: ['xX0001', '10006', '102', '', '2018-02-01', 4142.45, 0.0, 40146.55, ''], 
    ...: ['xX0001', '10006', '200', '', '2018-02-02', 14367.539999999999, 0.0, 41496.42999999999, ''], 
    ...: ['xX0001', '10006', '200', '', '2018-02-01', 12663.27, 0.0, 56043.94, '']]
In [52]: sorted(a, key=lambda b: b[4])
Out[52]: 
[['xX0001', '10006', '102', '', '2018-02-01', 4142.45, 0.0, 40146.55, ''],
 ['xX0001', '10006', '200', '', '2018-02-01', 12663.27, 0.0, 56043.94, ''],
 ['xX0001', '10006', '102', '', '2018-02-02', 3233.9, 0.0, 36816.18, ''],
 ['xX0001',
  '10006',
  '200',
  '',
  '2018-02-02',
  14367.539999999999,
  0.0,
  41496.42999999999,
  '']]

In [53]: sorted(a, key=lambda b: b[4])

solved Sorting a python list based on date? [closed]