<%@ Language=VBScript %>
<%
Option Explicit
Response.Expires = 0
On Error Resume Next
'*****************************************************************
'Variablendeklarationen
Dim arrintnumbers
Dim arrstrbez
Dim arrelement
'*****************************************************************
'Variableninitialisierung
arrstrbez = Array("WebMaster/in","WebPublisher/in", _
"PC-Supporter/in", "Netzwerkspezialist/in", "Applikationsentwickler/in")
arrintnumbers = Array(6,5,4,7,3,9,2,8,1)
'*****************************************************************
'Lokale Prozeduren und Funktionen
Sub procarrquicksort (ByRef arrvar, ByVal intl, ByVal intr)
Dim inti, intj, intpivot, vartemp
inti = intl
intj = intr
intpivot = arrvar((intl + intr)\2)
Do
Do While arrvar(inti) < intpivot
inti = inti + 1
Loop
Do While intpivot < arrvar(intj)
intj = intj - 1
Loop
If inti <= intj Then
vartemp = arrvar(intj)
arrvar(intj) = arrvar(inti)
arrvar(inti) = vartemp
inti = inti + 1
intj = intj - 1
End If
Loop While inti <= intj
If intl <= intj Then
call procarrquicksort (arrvar, intl, intj)
End If
If inti <= intr Then
call procarrquicksort (arrvar, inti, intr)
End If
End Sub
'*****************************************************************
'Anfang Code
'*****************************************************************
'Anfang <html>
%>
<!--#include virtual="asppages/silvi/_include/preheader.inc" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>ASP nützliche Routinen: Array sortieren mit Quicksort
</title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<!--#include virtual="asppages/silvi/_include/header.inc" -->
</head>
<body>
<%
'*****************************************************************
'Code innerhalb der HTML-Seite
Response.Write("<p><b>Strings in ASP sortieren mit Quicksort</b></p>")
Response.Write("<i>Vor Sortierung:</i><br />")
For each arrelement in arrstrbez
Response.Write(arrelement & "<br />" & vbCrLf)
Next
call procarrquicksort(arrstrbez, 0, UBound(arrstrbez))
Response.Write(" <br /><i>Nach Sortierung:</i><br />")
For each arrelement in arrstrbez
Response.Write(arrelement & "<br />" & vbCrLf)
Next
'Zahlen sortieren
Response.Write(" <br /><p><b>Zahlen in ASP sortieren mit Quicksort</b></p>")
Response.Write("<i>Vor Sortierung:</i><br />")
For each arrelement in arrintnumbers
Response.Write(arrelement & "<br />" & vbCrLf)
Next
call procarrquicksort(arrintnumbers, 0, UBound(arrintnumbers))
Response.Write("<i> <br />Nach Sortierung:</i><br />")
For each arrelement in arrintnumbers
Response.Write(arrelement & "<br />" & vbCrLf)
Next
%>
<!--#include virtual="asppages/silvi/_include/inchtmlnachspann.asp" -->
</body>
</html>
Demo: beispiele/070quicksortonedimensionalarray.asp
Letzter Update:
26.12.2021 16:48
Zurück zur
Liste mit ASP-Beispielen auf
www.ecotronics.ch