Rank a member in the leaderboard.

        @param member [String] Member name.
        @param score [float] Member score.
        @param member_data [String] Optional member data.
970055
def rank_member(self, member, score, member_data=None):
        '''
        
        '''
        self.rank_member_in(self.leaderboard_name, member, score, member_data)
285026
def zadd(self, key, score, member, *pairs, exist=None):
        
        if not isinstance(score, (int, float)):
            raise TypeError("score argument must be int or float")
        if len(pairs) % 2 != 0:
            raise TypeError("length of pairs must be even number")

        scores = (item for i, item in enumerate(pairs) if i % 2 == 0)
        if any(not isinstance(s, (int, float)) for s in scores):
            raise TypeError("all scores must be int or float")

        args = []
        if exist is self.ZSET_IF_EXIST:
            args.append(b'XX')
        elif exist is self.ZSET_IF_NOT_EXIST:
            args.append(b'NX')

        args.extend([score, member])
        if pairs:
            args.extend(pairs)
        return self.execute(b'ZADD', key, *args)
1238756
def rank v
      ret = redis.zrank rediskey, to_redis(v)
      ret.nil? ? nil : ret.to_i
    end
351944
def remove(self, member):
        
        if member not in self:
            return False
        score = self._members[member]
        score_index = bisect_left(self._scores, (score, member))
        del self._scores[score_index]
        del self._members[member]
        return True
1137914
function score ($phone_number, $account_lifecycle_event, array $other = []) {
    return $this->post(sprintf(self::SCORE_RESOURCE, $phone_number), array_merge($other, [
      "account_lifecycle_event" => $account_lifecycle_event
    ]));
  }
508336
def update_score_summary(sender, **kwargs):
        
        score = kwargs['instance']
        try:
            score_summary = ScoreSummary.objects.get(
                student_item=score.student_item
            )
            score_summary.latest = score

            # A score with the "reset" flag set will always replace the current highest score
            if score.reset:
                score_summary.highest = score
            # The conversion to a float may return None if points possible is zero
            # In Python, None is always less than an integer, so any score
            # with non-null points possible will take precedence.
            elif score.to_float() > score_summary.highest.to_float():
                score_summary.highest = score
            score_summary.save()
        except ScoreSummary.DoesNotExist:
            ScoreSummary.objects.create(
                student_item=score.student_item,
                highest=score,
                latest=score,
            )
        except DatabaseError as err:
            logger.exception(
                u"Error while updating score summary for student item {}"
                .format(score.student_item)
            )
649161
def members(refresh = false)
      @members = nil if refresh
      @members ||= safe_members.sort{|a,b| a.to_s <=> b.to_s}
    end
851588
protected void doForwardViterbi(Node[][] lattice, Instance carrier) {
		for (int l = 1; l < lattice.length; l++) {
			for (int c = 0; c < lattice[l].length; c++) {
				if (lattice[l][c] == null)
					continue;

				float bestScore = Float.NEGATIVE_INFINITY;
				int bestPath = -1;
				for (int p = 0; p < lattice[l - 1].length; p++) {
					if (lattice[l - 1][p] == null)
						continue;
					
					float score = lattice[l - 1][p].score
							+ lattice[l][c].trans[p];
					if (score > bestScore) {
						bestScore = score;
						bestPath = p;
					}
				}
				bestScore += lattice[l][c].score;
				lattice[l][c].addScore(bestScore, bestPath);
			}
		}
	}
479047
public function leaderboardAction()
    {
        $filter = $this->getEvent()->getRouteMatch()->getParam('filter');
        
        $user = null;
        $userId = $this->params()->fromQuery('user_id');
        $teamId = $this->params()->fromQuery('team_id');
        $search = $this->params()->fromQuery('name');
        $order = $this->params()->fromQuery('order');
        $dir = $this->params()->fromQuery('dir');
        $display = $this->params()->fromQuery('display');

        $lb = $this->getLeaderboardTypeService()->getLeaderboardTypeMapper()->findOneBy(array('name'=>$filter));
        if ($lb && $lb->getType()==='user' && $userId) {
            // get a positioned leaderboard on this user_id
            $leaderboard = $this->getLeaderboardService()->getLeaderboardQuery($filter, 0, $search, $order, $dir, $userId);
        } elseif ($lb && $lb->getType()==='team' && $teamId) {
            // get a positioned leaderboard on this team_id
            $leaderboard = $this->getLeaderboardService()->getLeaderboardQuery($filter, 0, $search, $order, $dir, $teamId);
        } else {
            $leaderboard = $this->getLeaderboardService()->getLeaderboardQuery($filter, 0, $search, $order, $dir);
        }

        if(!empty($userId)){
            $user = $this->getServiceLocator()->get('playgrounduser_user_service')->getUserMapper()->findById($userId);
        }
        $filters = $this->getLeaderboardTypeService()->getLeaderboardTypeMapper()->findAll();

        $paginator = new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\ArrayAdapter($leaderboard));
        $paginator->setItemCountPerPage(10);
        $paginator->setCurrentPageNumber($this->getEvent()->getRouteMatch()->getParam('p'));

        return new ViewModel(
            array(
                'searchedUser' => $user,
                'userId' => $userId,
                'display' => $display,
                'teamId' => $teamId,
                'search' => $search,
                'filter' => $filter,
                'filters' => $filters,
                'leaderboard' => $paginator,
                'order' => $order,
                'dir' => $dir
            )
        );
    }
656630
def get_score(self, member, default=None, pipe=None):
        
        pipe = self.redis if pipe is None else pipe
        score = pipe.zscore(self.key, self._pickle(member))

        if (score is None) and (default is not None):
            score = float(default)

        return score
588019
private List<MemberState> assignMembers(int index, List<MemberState> sortedMembers) {
    List<MemberState> members = new ArrayList<>(sortedMembers.size());
    for (int i = 0; i < sortedMembers.size(); i++) {
      if ((i + 1) % index == 0) {
        members.add(sortedMembers.get(i));
      }
    }
    return members;
  }
356902
def sort(ranked_records)
      ranked_records.sort { |a, b|
        a_score = a.last
        a_id = a.first.is_a?(Fixnum) ? a.first : a.first.id

        b_score = b.last
        b_id = b.first.is_a?(Fixnum) ? b.first : b.first.id

        if a_score == b_score
          a_id <=> b_id
        else
          b_score <=> a_score # We want the records with better relevance first.
        end

      }
    end
505836
def rank_for_in(self, leaderboard_name, member):
        '''
        
        '''
        if self.order == self.ASC:
            try:
                return self.redis_connection.zrank(
                    leaderboard_name, member) + 1
            except:
                return None
        else:
            try:
                return self.redis_connection.zrevrank(
                    leaderboard_name, member) + 1
            except:
                return None
1284042
def add_member(number)
      pnum = number.to_i
      raise "'#{number}' is not a valid as a team member player number" if pnum == 0 && !number.to_s.match(/^[^\d]*0/)
      raise "can't add duplicate player number #{pnum} to team '#{@name}'" if @members.include?(pnum)
      @members.push(pnum)
    end
470234
def remove_members_in_score_range_in(
            self, leaderboard_name, min_score, max_score):
        '''
        
        '''
        self.redis_connection.zremrangebyscore(
            leaderboard_name,
            min_score,
            max_score)
449347
private static Boolean hasMembershipProps(final Map<IRI, Long> data) {
        return data.containsKey(LDP.membershipResource) &&
            data.getOrDefault(LDP.hasMemberRelation, 0L) + data.getOrDefault(LDP.isMemberOfRelation, 0L) == 1L;
    }
460784
function sortedByScoreDesc(players) {
		return players.slice().sort(function(a, b) {
			if (b.score == a.score)
				return a.name.localeCompare(b.name);		// stabalize the sort
			return b.score - a.score;

		});
	}