8000 Add gulag sort · AllAlgorithms/javascript@239b9c2 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 239b9c2

Browse files
committed
Add gulag sort
1 parent d083316 commit 239b9c2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sorting/gulagSort.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const gulagSort = ls => {
2+
if (!ls.length) return []
3+
4+
const [x, y, ...xs] = ls
5+
6+
return y == null ?
7+
[x] : x < y ?
8+
[x, ...gulagSort([y, ...xs])] : gulagSort([y, ...xs])
9+
}

0 commit comments

Comments
 (0)
0