Saturday, September 19, 2015

An Efficient Quick Sort Function in Python

An Efficient Quick Sort Function


def EQS(arr):
    if len(arr) <= 1:
        return arr
    else:
        return EQS([x for x in arr[1:] if x < arr[0]]) + [arr[0]] + \
            EQS([x for x in arr[1:] if x >= arr[0]])


End of Function-----An Efficient Quick Sort Function in Python

 

example = [15,4,2,6,17,4,11,19]

print(EQS(example))

No comments:

Post a Comment