Utilities
Utility functions for working with Nexar models.
sort_players_by_rank(players, *, descending=True, ranked_queue_type=Queue.RANKED_SOLO_5x5)
async
Return a list of Player objects sorted by their ranked queue rank.
This function will automatically fetch league entries for each player if not already loaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
players
|
Sequence[Player]
|
Sequence of Player objects |
required |
descending
|
bool
|
If True (default), highest rank first. If False, lowest first. |
True
|
ranked_queue_type
|
Queue
|
QueueID.RANKED_SOLO_5x5 or RANKED_FLEX_SR |
RANKED_SOLO_5x5
|
Returns:
| Type | Description |
|---|---|
list[Player]
|
List of Player objects sorted by rank (unranked players last). |
Example
Source code in nexar/utils.py
team_total_percentage(participants, target_participant, stat_selector)
Calculate the percentage of a specific stat for a participant relative to their team's total for that stat.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
participants
|
ParticipantList
|
List of all participants in the match. |
required |
target_participant
|
Participant
|
The participant for whom to calculate the percentage. |
required |
stat_selector
|
Callable[[Participant], int | float]
|
Lambda expression that takes a Participant and returns the specific stat to calculate |
required |
Returns:
| Type | Description |
|---|---|
float
|
The percentage of the stat for the target participant relative to their team's total for that stat. |