-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsort-class.asp
118 lines (99 loc) · 2.88 KB
/
sort-class.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<%
Class sortk
'---------------------------------------------
' Scripting Dictionary Sort Class
' For Classic ASP
' by Anthony Burak DURSUN 2019 (c)
' badursun@gmail.com
' https://github.com/badursun/
' Original Raw Code "Sorting a Dictionary Object" By Aaron A.
' http://www.4guysfromrolla.com/webtech/062701-1.shtml
'---------------------------------------------
' Class Init
'-----------------------------------
Private Sub Class_Initialize()
On Error Resume Next
End Sub
' Class Terminate
'-----------------------------------
Private Sub Class_Terminate()
End Sub
' Grab Forms Data And Add Dictionary
'-----------------------------------
Public Property Get GrabForms(dictName)
If Not TypeName(dictName) = "Dictionary" Then
Set d = Server.CreateObject("Scripting.Dictionary")
Else
Set d = dictName
End If
For Each Item in Request.Form
d.Add Item, Request.Form(Item)
Next
Set GrabForms = d
Set d = Nothing
End Property
' Build Array
'-----------------------------------
Private Sub BuildArray(objDict, aTempArray)
Dim nCount, strKey
nCount = 0
Redim aTempArray(objDict.Count - 1)
For Each strKey In objDict.Keys
aTempArray(nCount) = strKey
nCount = nCount + 1
Next
End Sub
' Sort Array by KeyName
'-----------------------------------
Private Sub SortArray(aTempArray)
Dim iTemp, jTemp, strTemp
For iTemp = 0 To UBound(aTempArray)
For jTemp = 0 To iTemp
If strComp(aTempArray(jTemp),aTempArray(iTemp)) > 0 Then
strTemp = aTempArray(jTemp)
aTempArray(jTemp) = aTempArray(iTemp)
aTempArray(iTemp) = strTemp
End If
Next
Next
End Sub
'
'-----------------------------------
Private Sub PrintDictionary(objDict, aTempArray)
Dim iTemp
For iTemp = 0 To UBound(aTempArray)
Response.Write(aTempArray(iTemp) & " - " & objDict.Item(aTempArray(iTemp)) & "<br>")
Next
End Sub
'
'-----------------------------------
Public Sub PrintSortedDictionary(objDict)
Dim aTemp
Call BuildArray(objDict, aTemp)
Call SortArray(aTemp)
Call PrintDictionary(objDict, aTemp)
End Sub
'
'-----------------------------------
Public Sub PrintUnSortedDictionary(objDict)
Dim aTemp
Call BuildArray(objDict, aTemp)
'Call SortArray(aTemp)
Call PrintDictionary(objDict, aTemp)
End Sub
'
'-----------------------------------
Public Property Get CreateDictionary()
Set CreateDictionary = Server.CreateObject("Scripting.Dictionary")
End Property
'
'-----------------------------------
Public Property Get AddData(DictName, DictKey, DictValue)
If Not TypeName(DictName) = "Dictionary" Then
Call Err.Raise("1004", "First create Dictionary", "You cannot assign without creating a dictionary. First Set variable by calling CreateDictionary() ")
End If
'Set Data = Server.CreateObject("Scripting.Dictionary")
DictName.Add DictKey, DictValue
End Property
End Class
%>