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:
Aarav Arya
2026-03-08 23:32:52 -04:00
committed by GitHub
parent 0324e6098d
commit 81fcb90f7b

View File

@@ -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