PEATDB/TableModels.py
def createSortMap(self, names, sortkey, reverse=0):
        """Create a sort mapping for given list"""
        import operator
        recdata = []
        for rec in names:            
            recdata.append(self.getRecordAttributeAtColumn(recName=rec, columnName=sortkey))
        #try create list of floats if col has numbers only
        try:            
            recdata = self.toFloats(recdata)
        except:
            pass
        smap = zip(names, recdata)
        #sort the mapping by the second key
        smap = sorted(smap, key=operator.itemgetter(1), reverse=reverse)        
        #now sort the main reclist by the mapping order
        sortmap = map(operator.itemgetter(0), smap)
        return sortmap
Create a sort mapping for given list
Create a sort mapping for given list
Create a sort mapping for given list
def createSortMap(self, names, sortkey, reverse=0):
        import operator
        recdata = []
        for rec in names:            
            recdata.append(self.getRecordAttributeAtColumn(recName=rec, columnName=sortkey))
        try:            
            recdata = self.toFloats(recdata)
        except:
            pass
        smap = zip(names, recdata)
        smap = sorted(smap, key=operator.itemgetter(1), reverse=reverse)        
        sortmap = map(operator.itemgetter(0), smap)
        return sortmap
def createSortMap ( self , names , sortkey , reverse = 0 ) : import operator recdata = [ ] for rec in names : recdata . append ( self . getRecordAttributeAtColumn ( recName = rec , columnName = sortkey ) ) try : recdata = self . toFloats ( recdata ) except : pass smap = zip ( names , recdata ) smap = sorted ( smap , key = operator . itemgetter ( 1 ) , reverse = reverse ) sortmap = map ( operator . itemgetter ( 0 ) , smap ) return sortmap
Create a sort mapping for given list
Create a sort mapping for given list
"""Create a sort mapping for given list""" #try create list of floats if col has numbers only #sort the mapping by the second key #now sort the main reclist by the mapping order
self
names
sortkey
reverse