From be78e0521f4a12742ff822defc723e1e869051dd Mon Sep 17 00:00:00 2001 From: CayoViegas <50140892+CayoViegas@users.noreply.github.com> Date: Fri, 18 Oct 2019 15:19:41 -0300 Subject: [PATCH] Create BogoSort.py --- allalgorithms/sorting/BogoSort.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 allalgorithms/sorting/BogoSort.py diff --git a/allalgorithms/sorting/BogoSort.py b/allalgorithms/sorting/BogoSort.py new file mode 100644 index 0000000..bafbb9b --- /dev/null +++ b/allalgorithms/sorting/BogoSort.py @@ -0,0 +1,17 @@ +# -*- coding: UTF-8 -*- +# +# BogoSort Algorithm +# The All â–²lgorithms library for python +# +# Contributed by: Cayo Viegas +# Github: @CayoViegas +# + +from random import shuffle + +def bogosort(seq): + while not all(x <= y for x, y in zip(seq, seq[1:])): + shuffle(seq) + + return seq +