PlotnikovPhilipp

Untitled

Sep 13th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. """
  2.  
  3.    Быстрая сортировка
  4.  
  5. """
  6. def quickSort(arr):
  7.     if len(arr) < 2: return arr
  8.     else:
  9.         pivot = arr[0]
  10.         less = [i for i in arr[1:] if i <= pivot]
  11.         greator = [i for i in arr[1:] if i > pivot]
  12.         return quickSort(less) + [pivot] + quickSort(greator)
  13. print(quickSort([10, 5, 2, 3])) # массив, который надо отсортировать
Add Comment
Please, Sign In to add comment