(array)
| 378 | array.message("Randomized") |
| 379 | |
| 380 | def insertionsort(array): |
| 381 | size = array.getsize() |
| 382 | array.reset("Insertion sort") |
| 383 | for i in range(1, size): |
| 384 | j = i-1 |
| 385 | while j >= 0: |
| 386 | if array.compare(j, j+1) <= 0: |
| 387 | break |
| 388 | array.swap(j, j+1) |
| 389 | j = j-1 |
| 390 | array.message("Sorted") |
| 391 | |
| 392 | def selectionsort(array): |
| 393 | size = array.getsize() |