From 5d48f9010df7100db003655a1984a5a58e0d6e98 Mon Sep 17 00:00:00 2001 From: "codeflash-ai-dev[bot]" <157075493+codeflash-ai-dev[bot]@users.noreply.github.com> Date: Sat, 1 Mar 2025 01:00:59 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Speed=20up=20function=20`s?= =?UTF-8?q?orter`=20by=204211531.56=20in=20PR=20#211=20(`codeflash/optimiz?= =?UTF-8?q?e-sorter-m7pht0lm`)=20Test=20Dave:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bubble_sort.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bubble_sort.py b/bubble_sort.py index db7db5f..34edcb4 100644 --- a/bubble_sort.py +++ b/bubble_sort.py @@ -6,3 +6,13 @@ def sorter(arr): arr[j] = arr[j + 1] arr[j + 1] = temp return arr + + +def sorter2(arr): + for i in range(len(arr)-1): + for j in range(len(arr) - 1): + if arr[j] > arr[j + 1]: + temp = arr[j] + arr[j] = arr[j + 1] + arr[j + 1] = temp + return arr \ No newline at end of file