All pastes #353977 Raw Edit

Untitled

public text v1 · immutable
·published 2007-02-13 18:16 UTC
rendered paste body
    def top(self, number):
        """ Says the N best scores to the channel  """
        #if len(self.scores) <= number:
        #    scores_list = self.scores.values().reverse()
        #else:
        print self.scores, "..."
        scores_list = self.scores.values()
        scores_list.sort(reverse=False)
        scores_list.reverse()
        print scores_list
        toplist = {}
        for cur_score in scores_list[0:number]:
            for i in self.scores:
                if self.scores[i] == cur_score:
                    if not toplist.has_key(cur_score):
                        toplist[cur_score] = [i]
                    elif not i in toplist[cur_score]:
                        toplist[cur_score].append(i)
        print toplist
        for i in toplist:
            self.context.say("%d- %s with %d points" % (toplist.keys().index(i)+1, " and ".join(toplist[i]), i))