Kan man sortera efter ex: filnamn med Server.CreateObject("Scripting.FileSystemObject") ????? Du kan läsa in dom i en array och därefter sortera dom med exempelvis quicksort och därefter skriva ut dom. Se detta exempel:Scripting.FileSystemObject
Och isåfall hur ???
BoboSv: Scripting.FileSystemObject
<%
Response.Write "<HTML><HEAD></HEAD><BODY BGCOLOR=""WHITE"">"
Sub QuickSort(vec,loBound,hiBound)
Dim pivot,loSwap,hiSwap,temp
'== This procedure is adapted from the algorithm given in:
'== Data Abstractions & Structures using C++ by
'== Mark Headington and David Riley, pg. 586
'== Quicksort is the fastest array sorting routine for
'== unordered arrays. Its big O is n log n
'== Two items to sort
if hiBound - loBound = 1 then
if vec(loBound) > vec(hiBound) then
temp=vec(loBound)
vec(loBound) = vec(hiBound)
vec(hiBound) = temp
End If
End If
'== Three or more items to sort
pivot = vec(int((loBound + hiBound) / 2))
vec(int((loBound + hiBound) / 2)) = vec(loBound)
vec(loBound) = pivot
loSwap = loBound + 1
hiSwap = hiBound
do
'== Find the right loSwap
while loSwap < hiSwap and vec(loSwap) <= pivot
loSwap = loSwap + 1
wend
'== Find the right hiSwap
while vec(hiSwap) > pivot
hiSwap = hiSwap - 1
wend
'== Swap values if loSwap is less then hiSwap
if loSwap < hiSwap then
temp = vec(loSwap)
vec(loSwap) = vec(hiSwap)
vec(hiSwap) = temp
End If
loop while loSwap < hiSwap
vec(loBound) = vec(hiSwap)
vec(hiSwap) = pivot
'== Recursively call function .. the beauty of Quicksort
'== 2 or more items in first section
if loBound < (hiSwap - 1) then Call QuickSort(vec,loBound,hiSwap-1)
'== 2 or more items in second section
if hiSwap + 1 < hibound then Call QuickSort(vec,hiSwap+1,hiBound)
End Sub 'QuickSort
Sub PrintArray(vec,lo,hi)
'== Simply print out an array from the lo bound to the hi bound.
Dim i
For i = lo to hi
Response.Write vec(i) & "<BR>"
Next
End Sub 'PrintArray
Randomize
Dim x(9)
For z = 0 to 9
x(z) = int(Rnd*1000)
If (Rnd < 0.5) then x(z) = x(z)-1000
Next
Response.Write "Here is a jumbled array:<BR>"
Call PrintArray(x,0,9)
Call QuickSort(x,0,9)
Response.Write "Now the array is sorted!</BR>"
Call PrintArray(x,0,9)
Response.Write "</BODY></HTML>"
%>