Salve ragazzi ho esigenza di ordinare un'array in maniera decrescente
ho utilizzato con successo il seguente script che però esegue l'ordine in maniera crescente.
esiste un sistema veloce per invertire l'ordine?
codice:
<%@ LANGUAGE = VBscript %>
<%

sub heapfy(byref V,j,byval n)
  k=j
  if ((2*j+1)<=n) then
    if (V(2*j+1)>V(k)) then
      k=2*j+1
    end if
  end if
  if ((2*j)<=n) then
    if (V(2*j)>V(k)) then
      k=2*j
    end if
  end if
  if (k<>j) then
    t=V(j)
    V(j)=V(k)
    V(k)=t
    call heapfy(V,k,n)
  end if
end sub

sub ordina(byref V)
  n=ubound(V)
  i=n\2
  while (i>=0)
    call heapfy(V,i,n)
    i=i-1
  wend
  i=n
  while (i>=1)
    t=V(i)
    V(i)=V(0)
    V(0)=t
    call heapfy(V,0,(i-1))
    i=i-1
  wend
end sub

a=array(2,3,5,1,9,4,7,6,8,11)
Response.Write("Array iniziale:
")
for i=0 to ubound(a)
  Response.Write(a(i)&" ")
next

call ordina(a)

Response.Write("
Array ordinato:
")
for i=0 to ubound(a)
  Response.Write(a(i)&" ")
next
%>