Quick Sort

    0

    0

    HARIGOVIND VALSAKUMAR

    PythonQuickSort
    HGV Public Cookbook

    Function to perform Quick sort.

    def quick_sort(collection):
        length = len(collection)
        if length <= 1:
            return collection
        else:
            pivot = collection.pop()
            greater, lesser = [], []
            for element in collection:
                if element > pivot:
                    greater.append(element)
                else:
                    lesser.append(element)
            return quick_sort(lesser) + [pivot] + quick_sort(greater)
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.