Skip to content

Commit 415eca0

Browse files
authored
!Gadeimnoprstu
1 parent f0739fc commit 415eca0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

sorts/gnome_sort.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
Gnome Sort Algorithm (A.K.A. Stupid Sort)
33
44
This algorithm iterates over a list comparing an element with the previous one.
5-
If order is not respected, it swaps element backward until
6-
order is respected with previous element.
7-
It resumes the initial iteration from element new position.
5+
If order is not respected, it swaps element backward until order is respected with
6+
previous element. It resumes the initial iteration from element new position.
87
98
For doctests run following command:
109
python3 -m doctest -v gnome_sort.py
@@ -18,9 +17,8 @@ def gnome_sort(lst: list) -> list:
1817
"""
1918
Pure implementation of the gnome sort algorithm in Python
2019
21-
Take some mutable ordered collection with heterogeneous
22-
comparable items inside as argument,
23-
return the same collection ordered by ascending.
20+
Take some mutable ordered collection with heterogeneous comparable items inside as
21+
arguments, return the same collection ordered by ascending.
2422
2523
Examples:
2624
>>> gnome_sort([0, 5, 3, 2, 2])
@@ -31,6 +29,9 @@ def gnome_sort(lst: list) -> list:
3129
3230
>>> gnome_sort([-2, -5, -45])
3331
[-45, -5, -2]
32+
33+
>>> "".join(gnome_sort(list(set("Gnomes are stupid!"))))
34+
' !Gadeimnoprstu'
3435
"""
3536
if len(lst) <= 1:
3637
return lst

0 commit comments

Comments
 (0)