# PriorityDescending¶

class `whalrus.``PriorityDescending`[source]

Descending order (highest is favoured).

Examples

```>>> Priority.DESCENDING.choice({'a', 'b'})
'b'
>>> Priority.DESCENDING.sort({'a', 'b'})
['b', 'a']
>>> Priority.DESCENDING.sort_pairs_rp({('a', 'b'), ('b', 'a'), ('a', 'c')})
[('b', 'a'), ('a', 'b'), ('a', 'c')]
```
`choice`(x: Union[set, list], reverse: bool = False) → object

Choose an element from a list, set, etc.

Parameters: x (list, set, etc.) – The list, set, etc where the element is to be chosen. reverse (bool) – If False (default), then we choose the “first” or “best” element in this priority order. For example, if this is the ascending priority, we choose the lowest element. If True, then we choose the “last” or “worst” element. This is used, for example, in `RuleVeto`. The chosen element (or None). When `x` is empty, return None. When `x` has one element, return this element. object
`compare`(c, d) → int[source]

Compare two candidates.

Parameters: c (candidate) – d (candidate.) – 0 if c = d, -1 if the tie is broken in favor of c over d, 1 otherwise. int
`sort`(x: Union[set, list], reverse: bool = False) → Optional[list]

Sort a list, set, etc.

The original list `x` is not modified.

Parameters: x (list, set, etc.) – reverse (bool) – If True, we use the reverse priority order. A sorted list (or None). list or None
`sort_pairs_rp`(x: Union[set, list], reverse: bool = False) → Optional[list]

Sort a list, set, etc. of pairs of candidates (for Ranked Pairs).

By default, it is in the normal priority order for the first element of the pair, and in the reverse priority order for the second element of the pair.

The original list `x` is not modified.

Parameters: x (list, set, etc.) – reverse (bool) – If True, we use the reverse priority order. A sorted list (or None). list or None