Next / Previous / Contents / Shipman's homepage

21.4. YearCollection.genYearsRev(): Generate years in reverse chronological order

noteweb
# - - -   Y e a r C o l l e c t i o n . g e n Y e a r s R e v

    def genYearsRev ( self ):
        '''Generate years in reverse chronological order
        '''

The set of keys to self.__yearMap is the set of years. We extract it, sort it, reverse it, and then generate the contained YearRow instances in that order.

noteweb
        #-- 1 --
        # [ yyyyList  :=  keys of self.__yearMap in descending
        #                 order ]
        yyyyList  =  self.__yearMap.keys()
        yyyyList.sort()
        yyyyList.reverse()

        #-- 2 --
        # [ generate the YearRow instances in self in order by
        #   the elements of yyyyList ]
        for yyyy in yyyyList:
            yield self[yyyy]

        #-- 3 --
        raise StopIteration