```ts
export function rankOf(score: number, scores: number[]): number {
  if (scores.length === 0) throw new Error("Input array must not be empty");

  let above = 0;
  for (const other of scores) {
    if (other > score) {
      above += 1;
    }
  }
  return above + 1;
}

/** Each score's rank, in the order the scores were given. */
export function rankAll(scores: number[]): number[] {
  const ordered = [...scores].sort((a, b) => b - a);
  const places: Record<number, number> = {};
  ordered.forEach((value, i) => {
    places[value] = i + 1;
  });

  let currentRank = 1;
  return scores.map((score) => {
    if (place[score] === undefined) throw new Error("Score not found in the sorted list");
    const rank = place[score];
    while (rank in places && places[rank] < currentRank) {
      currentRank++;
    }
    return currentRank;
  });
}
```