MCPcopy Create free account
hub / github.com/geekcomputers/Python / oddEvenSort

Function oddEvenSort

Sorting Algorithms/brickSort.py:5–21  ·  view source on GitHub ↗
(arr, n)

Source from the content-addressed store, hash-verified

3
4
5def oddEvenSort(arr, n):
6 # Initially array is unsorted
7 isSorted = 0
8 while isSorted == 0:
9 isSorted = 1
10 temp = 0
11 for i in range(1, n - 1, 2):
12 if arr[i] > arr[i + 1]:
13 arr[i], arr[i + 1] = arr[i + 1], arr[i]
14 isSorted = 0
15
16 for i in range(0, n - 1, 2):
17 if arr[i] > arr[i + 1]:
18 arr[i], arr[i + 1] = arr[i + 1], arr[i]
19 isSorted = 0
20
21 return
22
23
24arr = [34, 2, 10, -9]

Callers 1

brickSort.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected