Last active
August 29, 2015 14:00
-
-
Save ricardosiri68/fdae8f5bdaaa68f4395a to your computer and use it in GitHub Desktop.
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 scalar_sort(l): | |
""" | |
*-------------------------------------------------------------------------- | |
* ordena una lista de forma escalar | |
*-------------------------------------------------------------------------- | |
* l: la lista que se quiere ordenar | |
* @return: la lista ordenada | |
""" | |
if not l: | |
return l | |
x = l[len(l) // 2] | |
minor = [e for e in l if e < x] | |
major = [e for e in l if e > x] | |
equal = [e for e in l if e == x] | |
return scalar_sort(minor) + equal + scalar_sort(major) | |
print(scalar_sort([4, 5, 2, 3, 8, 3, 5])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment