def find_leader(self):
        """returns the minimum peer that is alive as the leader"""
        # sort the replicas first
        replicas = sorted(self.replicas.items(), key=lambda t: t[0])
        if self.debug: self.logger.write("State", "All Replicas in my view:%s" %str(replicas))
        for (replica,liveness) in replicas:
            if liveness == 0:
                del replicas
                if self.debug: self.logger.write("State", "Leader is %s" %str(replica))
                return replica
        del replicas
        if self.debug: self.logger.write("State", "Leader is me")
        return self.me
dataset/ETHPy150Open denizalti/concoord/concoord/replica.py/Replica.find_leader/original