Ministério da Educação
Brasil um país de todos
Personal tools
Navigation
Log in


Forgot your password?
 
Document Actions

quicksort.py

by Cicero Garrozi last modified 2015-01-15 05:29

Click here to get the file

Size 1 kB - File type text/python-source

File contents

def quicksort(lista):
    if len(lista) < 2:
        return lista
    p=lista[0]
    menores = []
    maiores = []
    iguais = []
    for i in lista:
        if i > p:
            maiores.append(i)
        elif i < p:
            menores.append(i)
        else:
            iguais.append(i)
    return quicksort(menores) + iguais + quicksort(maiores)   

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: