Skip to content

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy