Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const insert = ([ first, ...rest], item) =>
- first === undefined
- ? [ item ]
- : item <= first
- ? [ item, first, ...rest ]
- : [ first, ...insert(rest, item)];
- const insertionSort = items => items.reduce(insert, []);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement