mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
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:
@@ -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