-
-
Save parzibyte/7ee868701f6b2f521358c717ad6c4b9a to your computer and use it in GitHub Desktop.
This file contains 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
func particion(arreglo *[]ProductoVendidoParaGrafica, izquierda, derecha int64) int64 { | |
var pivote = (*arreglo)[izquierda] | |
for { | |
for (*arreglo)[izquierda].VecesVendido > pivote.VecesVendido { | |
izquierda++ | |
} | |
for (*arreglo)[derecha].VecesVendido < pivote.VecesVendido { | |
derecha-- | |
} | |
if izquierda >= derecha { | |
return derecha | |
} else { | |
(*arreglo)[izquierda], (*arreglo)[derecha] = (*arreglo)[derecha], (*arreglo)[izquierda] | |
izquierda++ | |
derecha-- | |
} | |
} | |
} | |
func quicksort(arreglo *[]ProductoVendidoParaGrafica, izquierda, derecha int64) { | |
if izquierda < derecha { | |
indiceParticion := particion(arreglo, izquierda, derecha) | |
quicksort(arreglo, izquierda, indiceParticion) | |
quicksort(arreglo, indiceParticion+1, derecha) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment