Sort Order With End Year and Start Year
Posted
by
Maletor
on Stack Overflow
See other posts from Stack Overflow
or by Maletor
Published on 2012-06-25T23:18:31Z
Indexed on
2012/06/26
3:16 UTC
Read the original article
Hit count: 209
I'm looking to write a comparator
to sort my items in a list.
For items without an end year they should be at the top.
For items with an end year they should be next.
For items with the same end year the one with the lowest start year should be next.
Something I have so far
[item.get('end_year'), item.get('start_year')]
Test sceanrios first is end year second is start year ("" is present)
"", ""
"", 2012
"", 2011
2012, 2005
2012, 2008
2011, 2011
2010, 2005
© Stack Overflow or respective owner