Order
How to sequence options, rows, loop iterations, and child blocks — the fixed and random keywords, plus the expression form that lets one question's order follow another or a stored list.
order: controls the sequence of items — options on a question, rows on
a grid, iterations on a loop, child blocks inside a block. It never changes
which items appear (that’s options.from / scale.from); only the order
in which they’re shown.
Two forms:
- A keyword —
fixed,random,randomEach,alphabetical,reverse,flip. - An expression — any accessor or list that resolves to an ordered
code list, e.g.
Q1.all,Q1.selected,hOrder.rows, or a literal[2, 4, 1, 3].
The expression form is new in v3.38.0. Together the two cover every pattern the authoring team has needed — simple shuffles, carry-forward (“show Q2 in the same order Q1 was shown”), programmer-defined orders from scripts, and stored sequences imposed later.
Keywords
| Keyword | What it does |
|---|---|
fixed | Default. Items appear in the authored order. |
random | Shuffled once per respondent and kept consistent across every question that shares the same code set. A brand rotation set here is the brand rotation the whole battery sees. |
randomEach | Shuffled independently for every question — the same options can land in a different order on each one. |
alphabetical | Sorted by label (A–Z). |
reverse | Reverse of authored order. |
flip | Half the respondents see authored order; the other half see it reversed. Used to balance primacy / recency bias. |
- qid: QBrand
type: multi
text: Which have you heard of?
order: random
options: brandList
A piped subset (options.from: QBrand.selected) inherits the parent
question’s order. You do not need to re-declare order: on the
follow-up — the shown order is set once per respondent and carried
through the whole battery.
The expression form
Any expression that resolves to an ordered list of codes is a valid
order: value. The engine runs the same evaluator it uses for
options.from, so anything legal there is legal here.
Reference another question’s shown order
- qid: QBrand
type: multi
order: random
options:
1: Apple
2: Samsung
3: Sony
4: Nokia
- qid: QFav
type: single
text: Which did you prefer?
options.from: QBrand.selected
order: QBrand.all # same sequence the respondent saw on QBrand
QBrand.all returns every option in the order it was rendered for
this respondent. If QBrand was randomized to 3, 1, 4, 2, the
follow-up shows the respondent’s picks in that same order.
Use .selected instead when you want only the chosen ones in shown
order:
order: QBrand.selected # the picks, in the order they were shown
Combine lists with .union
- qid: QRecommend
type: multi
text: Which would you recommend?
options: brandList
options.from: QBrand.all.union(QTried.selected) # membership
order: QBrand.all.union(QTried.selected) # same sequence
.union concatenates with dedup — QBrand’s codes first, then any
QTried codes that aren’t already in the list. Match order: to
options.from when you want membership and sequence to come from the
same expression.
A def function from a script
- script: |
def primaryFirst():
return union(QPrimary.selected, QOther.selected)
- qid: QRating
type: gridSingle
options: brandList
order: primaryFirst()
scale:
1: Poor
2: Fair
3: Good
The function returns an ordered list; the engine resolves it per respondent. Good when the ordering rule is complex enough to deserve a name.
Literal list
- qid: QBlocks
type: single
options:
1: Alpha
2: Beta
3: Gamma
4: Delta
order: [2, 4, 1, 3]
Codes appear in the exact order you list. The comma form 2, 4, 1, 3
is also accepted. Codes not in the authored domain publish a warning
(dynamic expressions can’t be statically checked, but a literal can).
A captured order imposed later — hOrder.rows
# capture a shuffle once, early in the survey
- qid: hBlockOrder
type: openList
input.source: js
visibility: hide
required: False
# populated by an entry script with the respondent's assigned sequence
- block: concept-rotation
order: hBlockOrder.rows
children:
- block:
id: 1
# ...
- block:
id: 2
# ...
Store an ordered list of codes in a hidden question or script variable,
then reference it from order:. The same captured sequence can drive
options, loop iterations, and child blocks across the whole survey.
What goes where
| Surface | Takes order: | Keyword | Expression |
|---|---|---|---|
single / multi / rank options | Yes | ✓ | ✓ |
openList / numberList rows | Yes | ✓ | ✓ |
gridSingle / gridMulti / gridNumber rows | Yes | ✓ | ✓ |
mixGrid rows (on the parent) | Yes | ✓ | ✓ |
scale.order (grid columns) | Yes | ✓ | ✓ |
col.order on gridNumber (alias of scale.order) | Yes | ✓ | ✓ |
loop (iteration sequence) | Yes | ✓ | ✓ |
block (child-block sequence) | Yes | ✓ | ✓ |
page (question sequence on the page) | Yes | ✓ | — keywords only |
group.order (sequence of groups within a question) | Yes | ✓ | — keywords only |
The two surfaces where the expression form is deferred — pages and
group.order — still take every keyword. Only the expression upgrade
is pending.
Types with no ordered list — open, number, info, lookup, cbc,
maxdiff, cardSort — don’t accept order: at all.
Semantics
A few rules apply the same way for every surface.
Membership vs. sequence
options.from / scale.from set membership (which items appear).
order: / scale.order: set sequence (the order they’re shown
in).
When both are present, membership comes from *.from and the sequence
is overridden by order:. When only order: is present, it sequences
the authored domain.
Anchors and isolate opt-outs are excluded
Anchored items (anchor: True) keep their pinned position regardless of
order:. Isolate opt-outs (isolate: True) are rendered outside the
orderable set and never participate in sequencing. The order expression
applies only to the movable, non-isolate items.
Unlisted items append in authored order
If an order: expression returns [2, 4] but the question has four
options 1 / 2 / 3 / 4, the respondent sees 2, 4, 1, 3 — the listed
codes first, then the unlisted ones in their current (authored, or
*.from returned) order.
Dedup, unknown codes
If the list repeats a code, the first occurrence wins. A code that isn’t a current member is ignored.
Unresolved expressions fall back to authored order
If an order: expression can’t resolve yet (an upstream question is
unanswered), the question falls back to authored order for that
render. Once the dependency resolves, the custom order applies. Same
behaviour options.from already has.
Grouped questions
A grouped question has two independent axes and order: is
confined to the group:
group.order:sequences the groups.order:sequences the options within each group, matched per-group against each group’s own codes. Codes from other groups are ignored for that group; a group’s unlisted options append in authored order.
Options cannot leave their group — a list like order: [12, 11, 21, 22]
where codes 11 / 12 live in group A and 21 / 22 live in group B
orders A as 12, 11 and B as 21, 22. It does not interleave
across groups.
Anchored groups stay pinned regardless of group.order:.
Loops — iterate in a source’s shown order
A loop whose membership comes from options.from can set its iteration
sequence with order:.
- qid: QBrandUse
type: multi
order: random
text: Which brands have you used?
options:
1: Apple
2: Samsung
3: Sony
4: Nokia
- loop:
id: brand-detail
options.from: QBrandUse.selected
order: QBrandUse.all
children:
- qid: QRecent{{ loop.rowCode }}
type: single
text: How recently did you use {{ loop.row.label }}?
options:
1: This week
2: This month
3: Longer
The respondent is shown brands in a random order (QBrandUse has
order: random). The loop iterates over the ones they picked, in
that same shown order — not authored, not click order.
Loops still need an authored options: or options.from: for
membership. order: only re-sequences those members.
Blocks — impose a stored sequence on child blocks
A block’s children can be re-ordered by id: using an expression.
- script: |
# the respondent is assigned one of six fixed sequences
def conceptOrder():
return hBlockOrder.rows
- block: concept-rotation
order: conceptOrder()
children:
- block:
id: 1
# concept A — questions kept together and in defined order
- block:
id: 2
# concept B
- block:
id: 3
# concept C
- block:
id: 4
# concept D
If hBlockOrder.rows holds [3, 1, 4, 2], the respondent sees
blocks 3, 1, 4, 2 — each block’s questions stay together and in
their defined order. The expression resolves against child block id:.
Keyword or expression — how the engine decides
A value is treated as a keyword if and only if it exactly matches
one of the reserved words fixed / random / randomEach / alphabetical / reverse / flip. Anything else is parsed as an expression —
including a bare comma list like 2, 4, 1, 3.
A mistyped keyword (randoms, alpha) therefore parses as an
expression; the validator will reject it as an unresolved reference.
This is intentional — a typo should fail loudly rather than silently
default to fixed.
If a question is itself coded random and you ever need to reference
it by name, use an explicit accessor like Qrandom.all — a bare
random always resolves to the keyword.
Determinism
The expression resolves per render against current answers. There’s no RNG inside it, so the editor preview and the respondent engine produce byte-identical sequences for a given answer set. That’s the primary correctness bar: a preview that shows one order and a respondent who sees another is a bug.
Keyword randomization (random / randomEach) is also deterministic —
seeded per respondent, stable across their session, and consistent
between every surface that shares the seed.
See also
- Choices & domains —
options,options.from,scale,group. - Masking — the
options.fromevaluator the order expression shares. - Loops — iteration sequence.
- Blocks — child-block sequence.
- Column naming — export columns are always stable regardless of display order.