indexOrders property
The indices the respective elements would move to upon ordering.
Example:
final xs = [1, 5, 3, 2, 10, 6].toNumericColumn(),
blank = <num>[0, 0, 0, 0, 0, 0],
indices = xs.indexOrders;
for (var i = 0; i < 6; i++) {
blank[indices[i]] = xs[i];
}
print(xs);
print(blank);
NumericColumn [1, 5, 3, 2, 10, 6]
[1, 2, 3, 5, 6, 10]
Output:
Implementation
List<int> get indexOrders {
final indices = orderedIndices;
return [for (var i = 0; i < length; i++) i]
..sort((a, b) => indices[a].compareTo(indices[b]));
}