Skip to main content

Reorder

Reorder widgetReorder widget

Rank a list by moving items into the order you want. It returns a list<string> - a full permutation of the option values, never a subset.

$p->reorder('basket', 'Rank your basket')
->options([
'apple' => 'Apple',
'carrot' => 'Carrot',
'tomato' => 'Tomato',
])
->default(['apple', 'carrot']) // Seed the starting order; omitted items are appended.
->pageSize(10); // Items visible before the list pages around the cursor.

Runnable script: playground/02-widgets-reorder.php.

Options

NameDescriptionRequiredDefault
options()The items to rank, as a value => label map.Yes-
default()Seeds the starting order; any omitted options are appended in declared order, so the ranking is always complete.NoDeclared order
pageSize()Items shown before the list pages around the cursor.No10

A description line can accompany the highlighted item, declared with ->option(..., description: ...).

Keyboard

KeyAction
/ Move the highlight, or carry a held item through the list
SpacePick the highlighted item up, or drop a held one
EnterDrop a held item, or accept when nothing is held
EscCancel

Display modes

In all four display modes - Unicode or ASCII, color on or off:

ANSINo ANSI
UnicodeReorder: Unicode + ANSIReorder: Unicode + ANSIReorder: Unicode + No ANSIReorder: Unicode + No ANSI
ASCIIReorder: ASCII + ANSIReorder: ASCII + ANSIReorder: ASCII + No ANSIReorder: ASCII + No ANSI

Option descriptions

The highlighted item's description, in every display mode:

ANSINo ANSI
UnicodeReorder option descriptions: Unicode + ANSIReorder option descriptions: Unicode + ANSIReorder option descriptions: Unicode + No ANSIReorder option descriptions: Unicode + No ANSI
ASCIIReorder option descriptions: ASCII + ANSIReorder option descriptions: ASCII + ANSIReorder option descriptions: ASCII + No ANSIReorder option descriptions: ASCII + No ANSI