8000 Merge pull request #53 from renanpvaz/master · AllAlgorithms/javascript@daac950 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit daac950

Browse files
authored
Merge pull request #53 from renanpvaz/master
Add gulag sort
2 parents d083316 + 239b9c2 commit daac950

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