A way to use Python which I don't know

Posted by Konie on Stack Overflow See other posts from Stack Overflow or by Konie
Published on 2012-11-11T02:35:53Z Indexed on 2012/11/11 5:01 UTC
Read the original article Hit count: 76

Filed under:

In this quicksort function:

def qsort2(list):
    if list == []: 
        return []
    else:
        pivot = list[0]
        # can't understand the following line
        lesser, equal, greater = partition(list[1:], [], [pivot], [])
    return qsort2(lesser) + equal + qsort2(greater)

def partition(list, l, e, g):
    if list == []:
        return (l, e, g)
    else:
        head = list[0]
        if head < e[0]:
            return partition(list[1:], l + [head], e, g)
        elif head > e[0]:
            return partition(list[1:], l, e, g + [head])
        else:
            return partition(list[1:], l, e + [head], g)

I don't understand the sentence below the comment. Can someone tell me what is the meaning of this sentence here?

© Stack Overflow or respective owner

Related posts about python