Ordenando arrays - Bubble Sort ASP

Este algoritmo de ordenação de array é provavelmente o mais conhecido e também o mais eficaz

<%
Dim arrValue
arrValue = Array(12,24,51,24,15,35,15,65,418)

Function BubbleSort(arrInt)
for i = UBound(arrInt) - 1 To 0 Step -1
for j= 0 to i
if arrInt(j)>arrInt(j+1) then
temp = arrInt(j+1)
arrInt(j+1) = arrInt(j)
arrInt(j) = temp
end if
next
next
BubbleSort = arrInt
end function

response.write Join(BubbleSort(arrValue),",")
%>

Postado por www.leolima77.com.br

Nenhum comentário:

Postar um comentário