---
title: "zremrangebyrank · RUAL Documentation"
description: "Removes the members of a sorted set by position, or all but the N with the highest scores. A RUAL redis block in the redis sorted sets group."
canonical: https://docs.rual.nl/block-types/redis/redis_zremrangebyrank
language: en
---

# zremrangebyrank

This block is part of the [`redis`](https://docs.rual.nl/block-types/redis) group and was last modified in core [`v15.0.3`](https://docs.rual.nl/core-versions/150003).

## Redis Key Selection Required

This block relies on a Redis key to perform its redis releated actions. You must manually select the Redis key you want to use in the flow in the blueprint using the Redis key selector modal. To access the modal, click the white button on the block.

Removes the members of a sorted set by position, or all but the N with the highest scores.

- flow

- set `value` required key of the sorted set

- keep highest `number` keep this many members with the highest scores and remove the rest

- start `number` first position to remove, 0 is the lowest score

- stop `number` last position to remove, -1 is the highest score

- flow

- removed `number`

- success `condition`

- error `value`

- key `value`

Two forms, never mixed. keep_highest N keeps the N members with the highest scores and removes the rest: a list of recents scored by time, capped at N after each redis_set_zadd. Or start and stop, 0-based positions counted from the lowest score, negative from the highest (-1 is the highest): start 0, stop 0 removes the lowest one; start 0, stop -1 empties the set; keep_highest N is start 0, stop -(N+1). removed is how many members went. Nothing has a default: MISSING_START_POSITION or MISSING_STOP_POSITION for a range with one end, INVALID_RANGE for a position that is not a number or for keep_highest together with a position, INVALID_KEEP for a keep_highest that is not a whole number from 1 up; each removes nothing. A key of another type is an error (WRONGTYPE ...), never an empty answer. In simulation nothing is written: success=true with error NOT_EXECUTED_IN_SIMULATION_MODE. Choosing the positions and removing them is one step, and that step is recorded for a minute under a name of its own: a command the client sends again after a lost reply answers what the first one removed and removes nothing more.

| `redis zremrangebyrank` |
| --- |
| `zremrangebyrank` |
| `trim sorted set` |
| `keep newest` |

## Version history

Introduced in [`v15.0.3`](https://docs.rual.nl/core-versions/150003).

## Service documentation

- [External API reference](https://redis.io/commands/zremrangebyrank/): This block wraps a third-party service. Click here for the service's own documentation of the underlying endpoint.

- [Back to `redis`](https://docs.rual.nl/block-types/redis): Return to the main group to view all sub-groups

- [Back to `redis sorted sets`](https://docs.rual.nl/block-types/redis?group=redis%20sorted%20sets): Return to the group to view all blocks within this group
