I have a problem. I have list of lists that look something like this:
[
[datetime.date(2019, 3, 29), Decimal('44819.75')],
[datetime.date(2019, 3, 29), Decimal('45000.00')],
[datetime.date(2019, 3, 28), Decimal('0.00')],
[datetime.date(2019, 3, 22), Decimal('-275.00')],
[datetime.date(2019, 3, 22), Decimal('-350.00')],
[datetime.date(2019, 3, 22), Decimal('-175.00')]
]
I need sorting to be on date field(1st one), but each set of same dates must be sorted in reverse order. Resulting list must look like this:
[
[datetime.date(2019, 3, 29), Decimal('45000.00')],
[datetime.date(2019, 3, 29), Decimal('44819.75')],
[datetime.date(2019, 3, 28), Decimal('0.00')],
[datetime.date(2019, 3, 22), Decimal('-175.00')],
[datetime.date(2019, 3, 22), Decimal('-350.00')],
[datetime.date(2019, 3, 22), Decimal('-275.00')],
]
As you can see list is ordered by date but, for the same dates list is reversed.
dates are still descending 2019-3-29 2019-3-28 2019-3-22 but for each date, if there more than 1 element for that date, items are reversed.
for 2019-3-29 there are 2 element
[datetime.date(2019, 3, 29), Decimal('44819.75')],
[datetime.date(2019, 3, 29), Decimal('45000.00')],
and in resulting list of lists order is reversed
[datetime.date(2019, 3, 29), Decimal('45000.00')],
[datetime.date(2019, 3, 29), Decimal('44819.75')],
Unfortunately i can not find most pythonic way to do that, only ugly nested cycles