title: Bubble sort implementation from Pseudocode
body: <p>Here is the pseudocode I have</p>
  
  <pre><code>Procedure
      i &lt;- n
      last &lt;- 1
      while i &gt; last do
          for j &lt;- 1 to i-1 do
              if t[j] &gt; t[j+1] do
                 t[j] &lt;-&gt; t[j+1] {switch values}
                 last &lt;- j
              end if
          end for
          i &lt;- last
          last &lt;- 1
      end while
   end
  </code></pre>
  
  <p>I just need to state why this is an improvement on the standard bubble sort and do a trace of the algorithm. That I can manage. To do some test and for learning purposes, I decided to code it in python. My implementation do not work.</p>
  
  <pre><code>def bubbleSort(arr):
      n = len(arr)
      i = n
      last = 1
  
      while (i &gt; last):
          for j in range(0, i-1):
              if arr[j] &gt; arr[j+1] :
                  arr[j], arr[j+1] = arr[j+1], arr[j]
                  last = j
          i = last
          last = 1
  
  # Driver code to test above
  arr = [5, 3, 89, 100, -4, 7, 45]
  
  bubbleSort(arr)
  </code></pre>
  
  <p>The output I get is 3 ,5 ,89,-4 ,7 ,45 ,100 witch mean that it only does the first pass in the inner loop but stop right after.</p>
  
  <p>Is there something I am translating wrong from the pseudocode ?</p>