September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,23 @@
|
|||
(() => {
|
||||
'use strict';
|
||||
|
||||
// disjointSort :: [a] -> [Int] -> [a]
|
||||
const disjointSort = (xs, indices) => {
|
||||
|
||||
// Sequence of indices discarded
|
||||
const indicesSorted = indices.sort(),
|
||||
subsetSorted = indicesSorted
|
||||
.map(i => xs[i])
|
||||
.sort();
|
||||
|
||||
return xs
|
||||
.map((x, i) => {
|
||||
const iIndex = indicesSorted.indexOf(i);
|
||||
return iIndex !== -1 ? (
|
||||
subsetSorted[iIndex]
|
||||
) : x;
|
||||
});
|
||||
};
|
||||
|
||||
return disjointSort([7, 6, 5, 4, 3, 2, 1, 0], [6, 1, 7]);
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue