18 lines
440 B
Python
18 lines
440 B
Python
|
def BubbleSort(arr: list):
|
||
|
n = len(arr)
|
||
|
for i in range(n):
|
||
|
for j in range(i + 1, n):
|
||
|
if arr[i] > arr[j]:
|
||
|
temp = arr[i]
|
||
|
arr[i] = arr[j]
|
||
|
arr[j] = temp
|
||
|
|
||
|
def QuickSort(arr: list):
|
||
|
n = len(arr)
|
||
|
anchor = arr[0]
|
||
|
for i in range(n):
|
||
|
if anchor > arr[i]:
|
||
|
temp = arr[i]
|
||
|
arr[i] = anchor
|
||
|
arr[j] = temp
|
||
|
|