Ordenando arrays - Bubble Sort ASP

Thursday, 28 August 2008 14:55 por leolima77
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),",")
%>

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categorias:   Dicas
Ferramentas:   E-mail | del.icio.us | digg | rec6 | linkk | Permalink