sort array godot
extends Node
class_name MATH
static func in_order(var number: Array):
var new_array = []
for i in number.size():
var result = smallest_number(number)
#adds smallest number to new array
new_array.append(result)
#removes the number from the variable number
number.remove(number.find(result))
return new_array
#finds the smallest number
static func smallest_number(number: Array) -> float:
var lowest_so_far = number[0]
for i in number.size() - 1:
if lowest_so_far > number[i + 1]:
lowest_so_far = number[i + 1]
return lowest_so_far