<sortIndices>
<sortIndices> is a General Operator
component that renders the positions that put its arguments in sorted order, rather
than the sorted values themselves. The first entry of the result is the index of the
smallest value, the second is the index of the next smallest, and so on.
It accepts everything <sort> accepts and orders values identically —
including sortByProp for sorting components by one of their properties. The
difference is only in what it reports.
Its value comes from being combined with indexing: $other[$perm[1]] reads one
list in the order determined by another.
Attributes and Properties
Attributes for <sortIndices>
Highlighted (3)
asListboolean. Default value: true. Whether to render the items separated by commas (true) or with no separator (false).
sortByProptext. Name of a property to sort by (e.g. "x" for sorting points by x-coordinate).
typekeyword. Component type to sort bare string children as. Omit it and they are read as what they look like: every piece naming a number sorts by value, anything else sorts alphabetically.
| Value | Description |
|---|---|
number | Read bare strings as numbers, ordered by value. |
math | Read bare strings as math expressions, ordered by value. |
text | Read bare strings as text, ordered alphabetically. |
boolean | Read bare strings as booleans, ordered with false before true. |
Sort order (3)
sortByComponentinteger. Default value: 1. Index of the component to sort by (when sorting vectors).
sortByProptext. Name of a property to sort by (e.g. "x" for sorting points by x-coordinate).
sortVectorsBykeyword. Whether to sort vectors by component or by magnitude.
| Value | Description |
|---|---|
displacement (default) | Sort vectors by their displacement components. |
tail | Sort vectors by the position of their tail point. |
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Properties for <sortIndices name="s">
Sort order (2)
$s.sortByComponentinteger. Index of the component to sort by (when sorting vectors).
$s.sortVectorsBytext. Whether to sort vectors by component or by magnitude.
Common to all components (4)
$s.doenetMLtext. The DoenetML source code that produced this component.
$s.hideboolean. Whether to hide this component from the rendered output.
$s.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$s.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: the sorting permutation
The smallest value, 10, is in position 2 of the original list, so the result starts with 2.
Example: sorting one list by another
Sorting one list by the values of another is not expressible with <sort> alone,
because <sort> returns the values it sorted and discards where they came from.
Example: sorting points by a coordinate
sortByProp works exactly as it does on <sort>: point has the smallest
-coordinate, so it comes first.