RosettaCodeData/Task/Sort-disjoint-sublist/00-TASK.txt

25 lines
921 B
Plaintext

{{Sorting Algorithm}}
[[Category:Sorting]]
Given a list of values and a set of integer indices into that value list, the task is to sort the values at the given indices, while preserving the values at indices outside the set of those to be sorted.
Make your example work with the following list of values and set of indices:
:: Values: <code>[7, <b>6</b>, 5, 4, 3, 2, <b>1</b>, <b>0</b>]</code>
:: Indices: <code>{6, 1, 7}</code>
Where the correct result would be:
:: <code>[7, <b>0</b>, 5, 4, 3, 2, <b>1</b>, <b>6</b>]</code>.
In case of one-based indexing, rather than the zero-based indexing above, you would use the indices <code>{7, 2, 8}</code> instead.
The indices are described as a set rather than a list but any collection-type of those indices without duplication may be used as long as the example is insensitive to the order of indices given.
;Cf.
* &nbsp; [[Order disjoint list items]]
<br><br>