---
library: "bootstrap"
slug: "Rank"
name: "Rank"
ref: "Rank#67c6"
hash: "sema:Rank#mh:SHA-256:67c6fb568c5fdcfbd0de64b8a5413e943378d421dee9d5614c827e3c539bde3f"
type: "Primitives"
layer: "Infrastructure"
version: "0.11.0"
root: "a6a3d1ff0f982ee30430c5b42f3784c8ec901fd68482cfc1bc30899c1e5e48c5"
license: null
url: "https://semahash.org/vocabularies/bootstrap/patterns/Rank"
---

# Rank

Order items by score

Infrastructure · Primitives

## Mechanism

Deterministic Sort. Applies a caller-supplied [ScoringFunction](https://semahash.org/vocabularies/bootstrap/patterns/ScoringFunction.md) to every element in the input Set and returns a List ordered by Score. Uses [Select](https://semahash.org/vocabularies/bootstrap/patterns/Select.md) to truncate to Top-K when requested.

## Invariants

- Conservation: Output set is a subset of Input set.
- Monotonicity: For all i, Score(Output[i]) >= Score(Output[i+1]).

## Failure modes

- Score Indeterminacy: Multiple items have identical scores.
- Incomparability: Scoring function returns values that cannot be strictly ordered.

## Where this came from

—

## Builds on

- [Select](https://semahash.org/vocabularies/bootstrap/patterns/Select.md) (composes_with)
- [ScoringFunction](https://semahash.org/vocabularies/bootstrap/patterns/ScoringFunction.md) (accepts)

## Used by

- [Abduction](https://semahash.org/vocabularies/bootstrap/patterns/Abduction.md) (references)
- [BeamSearch](https://semahash.org/vocabularies/bootstrap/patterns/BeamSearch.md) (references)
- [Prioritize](https://semahash.org/vocabularies/bootstrap/patterns/Prioritize.md) (composes_with)

## Identity

- Library: bootstrap 0.11.0 (root a6a3d1ff0f98)
- Ref: Rank#67c6
- Hash: sema:Rank#mh:SHA-256:67c6fb568c5fdcfbd0de64b8a5413e943378d421dee9d5614c827e3c539bde3f

## Links

- Page: https://semahash.org/vocabularies/bootstrap/patterns/Rank
- JSON: https://semahash.org/vocabularies/bootstrap/patterns/Rank.json
- Library: https://semahash.org/vocabularies/bootstrap
- Library index: https://semahash.org/vocabularies/bootstrap/index.json
