From 48553da785f9233311ae59dd6eb93f79cf675965 Mon Sep 17 00:00:00 2001 From: sakuralethe Date: Fri, 26 Apr 2019 17:43:51 +0800 Subject: [PATCH] variable in function should be lowercase (#768) --- sorts/quick_sort.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sorts/quick_sort.py b/sorts/quick_sort.py index 136cbc021..e01d319a4 100644 --- a/sorts/quick_sort.py +++ b/sorts/quick_sort.py @@ -12,7 +12,7 @@ python quick_sort.py from __future__ import print_function -def quick_sort(ARRAY): +def quick_sort(collection): """Pure implementation of quick sort algorithm in Python :param collection: some mutable ordered collection with heterogeneous @@ -29,14 +29,14 @@ def quick_sort(ARRAY): >>> quick_sort([-2, -5, -45]) [-45, -5, -2] """ - ARRAY_LENGTH = len(ARRAY) - if( ARRAY_LENGTH <= 1): - return ARRAY + length = len(collection) + if length <= 1: + return collection else: - PIVOT = ARRAY[0] - GREATER = [ element for element in ARRAY[1:] if element > PIVOT ] - LESSER = [ element for element in ARRAY[1:] if element <= PIVOT ] - return quick_sort(LESSER) + [PIVOT] + quick_sort(GREATER) + pivot = collection[0] + greater = [element for element in collection[1:] if element > pivot] + lesser = [element for element in collection[1:] if element <= pivot] + return quick_sort(lesser) + [pivot] + quick_sort(greater) if __name__ == '__main__':