Created
          July 13, 2011 02:41 
        
      - 
      
 - 
        
Save zerohours/1079615 to your computer and use it in GitHub Desktop.  
    Quicksort on Python
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def quicksort(datos, primero, ultimo): | |
| i = primero | |
| j = ultimo | |
| pivote = (datos[primero] + datos[ultimo]) / 2 | |
| while i < j: | |
| while datos[i] < pivote: | |
| i+=1 | |
| while datos[j] > pivote: | |
| j-=1 | |
| if i <= j: | |
| aux = datos[i] | |
| datos[i] = datos[j] | |
| datos[j] = aux | |
| i+=1 | |
| j-=1 | |
| if primero < j: | |
| datos = quicksort(datos, primero, j) | |
| if ultimo > i: | |
| datos = quicksort(datos, i, ultimo) | |
| return datos | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment