Sorting: Bubble Sort

  • + 0 comments

    Python:

        s = 0
        for i in range(1, len(a)):
            for j in range(i):
                if a[j] > a[i]:
                    s += 1
                    a[i], a[j] = a[j], a[i]