-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharray-sorting.asp
More file actions
64 lines (53 loc) · 1.61 KB
/
array-sorting.asp
File metadata and controls
64 lines (53 loc) · 1.61 KB
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
<%
'**********************************************
'**********************************************
' _ _
' /\ | (_)
' / \ __| |_ __ _ _ __ ___
' / /\ \ / _` | |/ _` | '_ \/ __|
' / ____ \ (_| | | (_| | | | \__ \
' /_/ \_\__,_| |\__,_|_| |_|___/
' _/ | Digital Agency
' |__/
'
'* Project : RabbitCMS
'* Developer: <Anthony Burak DURSUN>
'* E-Mail : badursun@adjans.com.tr
'* Corp : https://adjans.com.tr
'**********************************************
'**********************************************
Function SortArray(vArr, vSort)
If (typeName(vArr) <> "Variant()" OR UBound(vArr) = 0) Then
Exit Function
End If
If vSort = "" Then vSort = "ASC"
Set outputLines = CreateObject("System.Collections.ArrayList")
For iArr = 0 To UBound(vArr)
outputLines.Add vArr(iArr)
Next
outputLines.Sort()
Select Case vSort
Case "DESC" : outputLines.Reverse()
Case Else
End Select
SortArray = outputLines.ToArray ' Array Çıktı
Set outputLines = Nothing
End Function
'**********************************************
' Demo
'**********************************************
Dim MyArray
MyArray = Array(1,5,9,7,3,2)
tmp_data = MyArray
Response.Write "<h4>Default Array</h4>"
Response.Write Join(tmp_data)
Response.Write "<hr>"
tmp_data = SortArray(MyArray, "ASC")
Response.Write "<h4>Sorted Array (ASC)</h4>"
Response.Write Join(tmp_data)
Response.Write "<hr>"
tmp_data = SortArray(MyArray, "DESC")
Response.Write "<h4>Sorted Array (ASC)</h4>"
Response.Write Join(tmp_data)
Response.Write "<hr>"
%>