# SORT_RO

> Read-only SORT, without the STORE option, safe to run on replicas.

URL: https://docs.hotkv.com/commands/sort_ro/

```
SORT_RO key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC | DESC] [ALPHA]
```

- Group: Server
- Complexity: O(N + M log M) where N is the number of elements and M the number sorted
- HotKV Cloud: all plans
- On-Premise: no license needed

`SORT_RO` is [SORT](https://docs.hotkv.com/commands/sort/index.md) without `STORE`. Because it never
writes, it is flagged read-only: you can send it to a replica, and ACL users
limited to read commands can run it. All other options and replies are those
of [SORT](https://docs.hotkv.com/commands/sort/index.md).

## Return value

An array of bulk strings, with nil (RESP2) or null (RESP3) for a missing
`GET` value. An empty array when `key` does not exist. Passing `STORE` gets
`ERR syntax error`; the other errors are those of [SORT](https://docs.hotkv.com/commands/sort/index.md).

## Examples

```
127.0.0.1:6379> RPUSH scores 30 4 120 15
(integer) 4
127.0.0.1:6379> SORT_RO scores DESC
1) "120"
2) "30"
3) "15"
4) "4"
127.0.0.1:6379> SORT_RO scores STORE out
(error) ERR syntax error
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[SORT](https://docs.hotkv.com/commands/sort/index.md), [READONLY](https://docs.hotkv.com/commands/readonly/index.md)