Skip to content

Instantly share code, notes, and snippets.

@Alfex4936
Last active August 4, 2020 03:50
Show Gist options
  • Select an option

  • Save Alfex4936/f36c1224dd8deb637edc2d3b949264ca to your computer and use it in GitHub Desktop.

Select an option

Save Alfex4936/f36c1224dd8deb637edc2d3b949264ca to your computer and use it in GitHub Desktop.
Bubble Sort
from win10toast import ToastNotifier
from random import randint
def bubbleSort(array):
n = len(array)
for i in range(n):
already_sorted = True
for j in range(n - i - 1):
if array[j] > array[j + 1]:
array[j], array[j + 1] = array[j + 1], array[j]
already_sorted = False
if already_sorted:
break
return array
toaster = ToastNotifier()
array = [randint(-3000, 3000) for i in range(3000)]
toaster.show_toast("Bubble Sort",
"The array is being sorted",
icon_path=None,
duration=5,
threaded=True)
# Thread
while toaster.notification_active():
bubbleSort(array)
toaster.show_toast("Bubble Sort",
f"The array is sorted {array}",
icon_path=None,
duration=10,
threaded=False)
# result gif
# https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fdocl5M%2FbtqGd1Ev2z0%2FoMC3PI1OihWCIvXMQun8q0%2Fimg.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment