I am beginner in python lists. I have a list of feature classes named by type and year of occurrence: feature class "a_05" occurred in 2005, feature class "b_03" occurred in 2003.
I would like to sort the items in a list increasingly by time they occurred (2003, 2005...), and if two types occurred in the same year, than they should be ordered alphabetically.
Let's say, list
fcs = [u'b_02', u'a_05', u'a_03', u'b_03']
should results in [ u'b_02', u'a_03', u'b_03', u'a_05']
,
i.e. first years (_02,_03,_03,_05)
and then alphabetically u'a_03', u'b_03'
.
Using simply fcs.sort()
my items are instead first sorted alphabetically, than by numbers: [u'a_03', u'a_05', u'b_02', u'b_03']
How can I alter my item names to be able to sort them first by numbers, not by the letters?