diff --git a/client/src/pages/guide/english/algorithms/sorting-algorithms/bubble-sort/index.md b/client/src/pages/guide/english/algorithms/sorting-algorithms/bubble-sort/index.md index eafa8636cb3..55325a67649 100644 --- a/client/src/pages/guide/english/algorithms/sorting-algorithms/bubble-sort/index.md +++ b/client/src/pages/guide/english/algorithms/sorting-algorithms/bubble-sort/index.md @@ -142,6 +142,21 @@ func bubbleSort(_ inputArray: [Int]) -> [Int] { } return numbers // return the sorted array } +``` +### Example in Python +```py + +def bubblesort( A ): + for i in range( len( A ) ): + for k in range( len( A ) - 1, i, -1 ): + if ( A[k] < A[k - 1] ): + swap( A, k, k - 1 ) + +def swap( A, x, y ): + tmp = A[x] + A[x] = A[y] + A[y] = tmp + ``` ### More Information