' Select sort
Function Selectsort (A_data)
Dim I, J, K
Dim bound, t
bound = UBound (a_data)
For i = 0 to Bound-1
K = i
For j = I+1 to Bound
If A_data (k) > A_data (j) Then
K = J
End If
Next
t = a_data (i)
A_data (i) = A_data (k)
A_data (k) = t
Next
Selectsort = A_data
End Function
' Quick sort
Function QuickSort (A_data)
Dim I, J
Dim bound, t
bound = UBound (a_data)
For i = 0 to Bound-1
For j = I+1 to Bound
If a_data (i) > A_data (j) Then
t = a_data (i)
A_data (i) = A_data (j)
A_data (j) = T
End If
Next
Next
QuickSort = A_data
End Function
' Bubble sort
Function Bubblesort (A_data)
Dim bound
bound = UBound (a_data)
Dim bsorted, I, t
bsorted = False
Do while bound > 0 and bsorted = False
bsorted = True
For i = 0 to Bound-1
If a_data (i) > A_data (i+1) Then
t = a_data (i)
A_data (i) = A_data (i+1)
A_data (i+1) = t
bsorted = False
End If
Next
bound = bound-1
Loop
Bubblesort = A_data
End Function
' Insert sort
Function Insertsort (A_data)
Dim bound
bound = UBound (a_data)
Dim I, J, t
For i = 1 to Bound
t = a_data (i)
j = I
Do While T<a_data (j-1) and j>0
A_data (j) = A_data (j-1)
j = J-1
Loop
A_data (j) = T
Next
Insertsort = A_data
End Function
' Output array
Sub Responsearray (A_data, str)
Dim s
s = ""
Response.Write "<b>" & str & ":</b>"
For i = 0 to UBound (a_data)
s = S & A_data (i) & ","
Next
s = Left (S, Len (s)-1)
Response.Write S
Response.Write "End Sub
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service