Why my sorting code doesn't working??
import random class Sort: def sort(self, arr): pass def compare(self, item1, item2): if item1 < item2: return 1 elif item1 > item2: return -1 else: return 0 def swap(self, item1, item2): tmp = item1 item1 = item2 item2 = tmp def isSorted(self, arr): prev = 0 for i, j in zip(arr[:-1], arr[1:]): now = self.compare(i, j) if prev * now == -1: return False prev = now return True class BubbleSort(Sort): def sort(self, arr): n = len(arr) for i in range(n): for j in range(n-i-1): if arr[j] > arr[j+1]: self.swap(arr[j], arr[j+1]) arr=[] for i in range(10): arr.append(random.randint(0, 11)) print(arr) bubblesort = BubbleSort() bubblesort.sort(arr) print(arr)