<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. |
Number display (5)
avoidScientificNotationIn developmentboolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.
displayDecimalsIn developmentinteger. Default value: 2. Number of decimal places to display when rendering this number.
displayDigitsIn developmentinteger. Default value: 3. Number of significant digits to display when rendering this number.
displaySmallAsZeroIn developmentnumber. Default value: 1e-14. Threshold below which numbers are displayed as zero.
padZerosIn developmentboolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
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.
Number display (5)
$s.avoidScientificNotationIn developmentboolean. Whether to render numbers in full decimal form rather than scientific notation.
$s.displayDecimalsIn developmentinteger. Number of decimal places to display when rendering this number.
$s.displayDigitsIn developmentinteger. Number of significant digits to display when rendering this number.
$s.displaySmallAsZeroIn developmentnumber. Threshold below which numbers are displayed as zero.
$s.padZerosIn developmentboolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Common to all components (8)
$s.disabledIn developmentboolean. Whether this component is disabled and cannot be interacted with.
$s.doenetMLtext. The DoenetML source code that produced this component.
$s.fixedIn developmentboolean. Whether this component's value is fixed and cannot be modified.
$s.fixLocationIn developmentboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$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.