Rotate a list randomly

Rotate a list by a random non-zero offset chosen between 1 and list-length-minus-1 - guarantees a visible shift on the first run (no accidental no-op). Same rotation mechanics as Rotate a list; this variant just picks N for you. Single-item lists pass through unchanged.

Input
Ready
Output
Live

Visible-on-first-run random rotation

The op is `1 + Math.floor(Math.random() * (length - 1))` - an integer N in the range `[1, length - 1]` inclusive. Zero is excluded on purpose so a fresh paint never produces an accidental no-op (which happens with `Math.floor(Math.random() * length)` about once every `length` runs).

Rotation itself is `all.slice(n).concat(all.slice(0, n))` - same mechanics as Rotate a list. This variant just picks the offset for you and always produces a visible shift.

Single-item lists pass through unchanged (the status bar says "single item - cannot rotate"). Empty input returns empty output. Otherwise every run produces a different rotation - no seed, no reproducibility.

How to use rotate a list randomly

  1. 1Paste your list into the input panel
  2. 2Output is your list rotated by a random non-zero offset
  3. 3Every run picks a new offset - output differs each time
  4. 4Single-item lists pass through unchanged
  5. 5For a chosen offset, use Rotate a list

Keyboard shortcuts

Drive ListShift without touching the mouse.

Shortcut Action
Ctrl ZUndo last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor
EscExit fullscreen
Ctrl KOpen the command palette to jump to any tool
Ctrl SSave current pipeline draft Plus
Ctrl PRun a saved pipeline Plus

What this tool actually does

Random offset from `[1, length-1]`, rotate by that amount.

Non-zero offset by construction

The op picks from `[1, length - 1]` inclusive, never 0. This guarantees a visible shift on every paint - unlike `Math.random() * length` which hits 0 roughly once every `length` runs and produces a no-op.

Wrap-around rotation

Items falling off the front wrap to the back. With a 5-item list and offset 2, item at index 0 moves to index 3. No items are dropped or duplicated.

Different every run

No seed input. Each call to the op gets a fresh `Math.random()` and thus a fresh offset. Same input, different outputs.

Single-item and empty lists

A one-item list passes through unchanged (the status bar notes "single item - cannot rotate"). Empty input returns empty output.

Not cryptographically secure

`Math.random` is fine for raffles and general shuffling but not security-critical work. For cryptographically-secure rotation, use `crypto.getRandomValues` directly.

Worked example

Random rotation - one possible result shown. Output varies on every run.

Input
apple
banana
cherry
date
elderberry
Output
cherry
date
elderberry
apple
banana

Behavior reference

No user options. These are the fixed rules.

Rule What it does Example
Offset range Random integer in `[1, length - 1]` - excludes 0 For a 5-item list: offset is 1, 2, 3, or 4
Wrap-around Items rotate; none dropped or duplicated Offset 2 on `A B C D E` → `C D E A B`
Single-item list Pass-through, status bar notes the no-op `[A]` → `[A]`
Empty input Empty output (empty)
Non-reproducible No seed; every run picks a new offset Different output every click

FAQ

Why is the offset guaranteed non-zero?
So the output is visibly different from the input on every run. A plain `Math.random() * length` can land on 0 about once every `length` runs, producing a confusing no-op. Excluding 0 keeps the tool honest about being a rotation.
How does this differ from Rotate a list?
Rotate a list takes a Shift-by N that you specify. This variant picks N randomly from `[1, length - 1]` every run. Same rotation mechanics; different source of N.
What happens with a single-item list?
The item passes through unchanged. Rotation cannot do anything useful on a one-item list, and the op returns the original item with a status-bar note.
Is the randomness cryptographically secure?
No - `Math.random` is suitable for general shuffling but not for security-critical use. For cryptographic randomness, use `crypto.getRandomValues` directly in code.
How is this different from Shuffle?
Shuffle fully permutes the list - every item can land anywhere. Rotate only shifts the starting point; relative order within the list is preserved. Pick shuffle for uniform mixing, rotate for "same list, different starting point".