Skip to content

Commit 64f4293

Browse files
authored
Merge pull request #11 from abc516/abc516/bogosort
add bogosort
2 parents 9860ae2 + 6ea35c1 commit 64f4293

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sorting/bogosort/bogosort.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export function bogoSort(arr: Array<number>): Array<number> {
2+
while (!isSorted(arr)){
3+
//shuffle code here.
4+
}
5+
return arr;
6+
}
7+
8+
function isSorted(data: Array<number>): boolean{
9+
for(let i = 0; i < data.length - 1; i++){
10+
if(data[i] > data[i + 1]) return false;
11+
}
12+
return true;
13+
}

0 commit comments

Comments
 (0)