Last active
September 19, 2017 11:51
-
-
Save vctr-uniq/0f3c5587e48ae57d7053f005eb157cc0 to your computer and use it in GitHub Desktop.
Bubble sort in GDScript (Godot Engine 2.1)
This file contains 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
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