Skip to content

Instantly share code, notes, and snippets.

@vctr-uniq
Last active September 19, 2017 11:51
Show Gist options
  • Save vctr-uniq/0f3c5587e48ae57d7053f005eb157cc0 to your computer and use it in GitHub Desktop.
Save vctr-uniq/0f3c5587e48ae57d7053f005eb157cc0 to your computer and use it in GitHub Desktop.
Bubble sort in GDScript (Godot Engine 2.1)
var notes = [7,2,5,1]
print("notes:", notes)
for i in range(notes.size()-1, -1, -1):
#print("i:", i)
for j in range(1,i+1,1):
#print("J:", j)
if notes[j-1] > notes[j]:
var temp = notes[j-1]
notes[j-1] = notes[j]
notes[j] = temp
print("sorted notes:", notes)
#output:
#notes:[7,2,5,1]
#soreted notes:[1,2,5,7]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment