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, but 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: [7, 6, 5, 4, 3, 2, 1, 0]
indices: {6, 1, 7}
Where the correct result would be:
[7, 0, 5, 4, 3, 2, 1, 6].
newLISP
(set 'values '(7 6 5 4 3 2 1 0))
(set 'positions '(6 1 7))
(set 'sorted-vals (sort (map (fn(n) (values n)) positions)))
(dolist (p (sort positions))
(setf (values p) (pop sorted-vals)))
values
(7 0 5 4 3 2 1 6)
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)