using Test function verificaSort() @test ordena([]) == [] @test ordena([1, 2, 3]) == [1, 2, 3] @test ordena([1, 1, 1]) == [1, 1, 1] @test ordena([3, 2, 1]) == [1, 2, 3] @test ordena([3, -12, 1]) == [-12, 1, 3] @test ordena([3, 5, 2, 76, 23, 1, 8, 7, 3, 1, 12]) == [1, 1, 2, 3, 3, 5, 7, 8, 12, 23, 76] println("Final dos testes") end function ordena(v) return bolha(v) end function troca(v, i, j) aux = v[i] v[i] = v[j] v[j] = aux end #selection sort function selecao(v) tam = length(v) for i in 1:tam min = v[i] ind = i for j in i + 1:tam if v[j] < min min = v[j] ind = j end end troca(v, i, ind) end return v end # Insertion function insercao(v) tam = length(v) for i in 2:tam j = i while j > 1 if v[j] < v[j - 1] troca(v, j, j - 1) else break end j = j - 1 end end return v end # bubble sort function bolha(v) tam = length(v) i = tam - 1 while i >= 1 for j in 1:i if v[j] > v[j + 1] troca(v, j, j + 1) end end i = i - 1 end return v end verificaSort()