Add type hints for bogo_sort.py (#14306)
* Added type hints for bogo_sort * Update bogo_sort.py --------- Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
This commit is contained in:
co-authored by
Maxim Smolskiy
parent
0324e6098d
commit
81fcb90f7b
+2
-2
@@ -16,7 +16,7 @@ python bogo_sort.py
|
||||
import random
|
||||
|
||||
|
||||
def bogo_sort(collection):
|
||||
def bogo_sort(collection: list) -> list:
|
||||
"""Pure implementation of the bogosort algorithm in Python
|
||||
:param collection: some mutable ordered collection with heterogeneous
|
||||
comparable items inside
|
||||
@@ -30,7 +30,7 @@ def bogo_sort(collection):
|
||||
[-45, -5, -2]
|
||||
"""
|
||||
|
||||
def is_sorted(collection):
|
||||
def is_sorted(collection: list) -> bool:
|
||||
for i in range(len(collection) - 1):
|
||||
if collection[i] > collection[i + 1]:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user