From b5f38ad475e44384d980c4e5fb5e90f9741aaf50 Mon Sep 17 00:00:00 2001 From: Tiago Garcia Date: Sat, 28 Sep 2024 17:57:24 +0100 Subject: [PATCH] Add Ex5.2 using quicksort Signed-off-by: Tiago Garcia --- aula2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aula2.py b/aula2.py index 17d1b4b..0c8ce16 100644 --- a/aula2.py +++ b/aula2.py @@ -42,4 +42,4 @@ def menor_e_resto_ordem(lista, f): # Exercicio 5.2 def ordenar_seleccao(lista, ordem): - pass + return lista if len(lista) <= 1 else ordenar_seleccao([x for x in lista[1:] if ordem(x, lista[0])], ordem) + [lista[0]] + ordenar_seleccao([x for x in lista[1:] if not ordem(x, lista[0])], ordem)