Answers for "sort number from smallest to largest in godot"

0

sort number from smallest to largest in 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
Posted by: Guest on August-28-2021

Code answers related to "sort number from smallest to largest in godot"

Browse Popular Code Answers by Language