File tree 2 files changed +37
-17
lines changed 2 files changed +37
-17
lines changed Original file line number Diff line number Diff line change @@ -4,21 +4,19 @@ please feel free to add and edit
4
4
5
5
## These have been added:
6
6
7
- * bubble sort
8
- * counting sort
9
- * quick sort
10
- * radix sort
11
- * insertion sort
12
- * selection sort
7
+ * Bubble sort
8
+ * Counting sort
9
+ * Quick sort
10
+ * Radix sort
11
+ * Insertion sort
12
+ * Selection sort
13
+ * Bogo sort
13
14
14
15
## These will be added:
15
16
16
- * pancake sort
17
+ * Pancake sort
17
18
* merge sort
18
- * insertion sort
19
- * bogo sort
20
- * pigeonhole sort
21
- * tim sort
22
- * heap sort
23
- * pancake sort
24
- * sudo bogo sort
19
+ * Pigeonhole sort
20
+ * Tim sort
21
+ * Heap sort
22
+ * Sudo bogo sort
Original file line number Diff line number Diff line change 6
6
import math
7
7
8
8
array = []
9
- size = 3
9
+ size = 10
10
10
count = [0 ]
11
11
out = [0 ]
12
12
rng = 10
@@ -148,7 +148,29 @@ def select():
148
148
149
149
#bogo sort
150
150
def bogo ():
151
- pass
151
+ # WARNING this can take a LONG time only run with fewer than 10 items to sort
152
+ global array
153
+ cont = True
154
+ #loop until the array is sorted
155
+ while cont == True :
156
+ out = []
157
+ cont = False
158
+ #loop till the starting array has no items in it
159
+ while len (array ) > 0 :
160
+ #move a random item to the end array
161
+ item = randint (0 ,len (array )- 1 )
162
+ out .append (array [item ])
163
+ array .remove (array [item ])
164
+ #test to see if the array is sorted
165
+ for i in range (len (out )- 1 ):
166
+ if out [i ] > out [i + 1 ]:
167
+ cont = True
168
+ break
169
+ array = []+ out
170
+
171
+ print (out )
172
+
173
+
152
174
#sudo bogo sort
153
175
def sudo_bogo ():
154
176
pass
@@ -178,5 +200,5 @@ def pancake():
178
200
srt ()
179
201
print (array , "unsorted" )
180
202
print ()
181
- bogo ()
203
+ merge_sort ()
182
204
print (sorted (og ), "sorted" )
You can’t perform that action at this time.
0 commit comments