Ir para conteúdo
Fórum Script Brasil
  • 0

Ordernar Array De Forma Crescente...


marcos_804

Pergunta

Pessoal, tem como ordernar uma array de forma crescente em asp?

Já vi isso em javascritp e PHP utilzando uma função "sort".

Tem alguma função que voces conhecam para eu armazenar estes valores em um array e depois chamar de forma crescente ou descrescente em asp...?

Desde já agradeço a atenção.

Marcos Oliveira

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

Function SelectionSort(TempArray, SortOrder)

Dim MaxVal, MaxIndex, i, x

' Step through the elements in the array starting with the last element.

For i = UBound( TempArray) To 0 Step -1

' Set MaxVal to the element in the array and save the

' index of this element as MaxIndex.

MaxVal = TempArray(i)

MaxIndex = i

' Check the selected sortorder of the array

' "<" for DESC and ">" for ASC

If SortOrder = "<" Then

' Loop through the remaining elements to see if any is

' larger than MaxVal. If it is then set this element

' to be the new MaxVal.

For x = 0 To i

If TempArray(x) < MaxVal Then

MaxVal = TempArray(x)

MaxIndex = x

End If

Next

Else

For x = 0 To i

If TempArray(x) > MaxVal Then

MaxVal = TempArray(x)

MaxIndex = x

End If

Next

End If

If MaxIndex < i Then

TempArray(MaxIndex) = TempArray(i)

TempArray(i) = MaxVal

End If

Next

SelectionSort = TempArray

End Function

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...