Created
July 23, 2025 03:52
-
-
Save UltiRequiem/d4f56746a334cfbf59e3819838b36495 to your computer and use it in GitHub Desktop.
my vars bruh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cool = [2,5,3,6,9] | |
def insertion_sort(nums): | |
for i in range(len(nums)): | |
min_index = i | |
for j in range(i+1, len(nums)): | |
if nums[j] < nums[i]: | |
min_index = j | |
nums[i],nums[min_index] = nums[min_index], nums[i] | |
return nums | |
def bubble_sort(nums): | |
n = len(nums) | |
for i in range(n): | |
for j in range(i+1,n-1): | |
if nums[j]> nums[j+1]: | |
nums[j+1], nums[j] = nums[j], nums[j+1] | |
return nums | |
def cool_sort(nums): | |
n = len(nums) | |
wip = True # It must start as true | |
while wip: | |
wip = False | |
for i in range(n -1): #last one will already be sorted | |
if nums[i] > nums[i+1]: | |
nums[i], nums[i+1] = nums[i+1], nums[i] | |
wip = True | |
return nums | |
cooler = bubble_sort(cool) | |
print(cooler) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment