I have the code below... it grabs data like this:
name1, name4, name2, name3
and list like this ([ ] is a checkbox):
[ ] name 1 [ ] name 4 [ ] name 2 [ ] name 3
<%
Set DicionarioMyData = CreateObject("Scripting.Dictionary")
Set MyData= TarefasConexaoMSSQL.Execute("SELECT A FROM TABLE")
If Not MyData.EOF Then
Do While Not MyData.EOF
ItensDoMyData = MyData("A")
If Not IsNull(ItensDoMyData) Then
ItensSeparadosDoMyData = Split(ItensDoMyData, ",")
For i = 0 To UBound(ItensSeparadosDoMyData)
ItensDoMyData = Trim(ItensSeparadosDoMyData(i))
If Not DicionarioMyData.Exists(ItensDoMyData) Then
DicionarioMyData.Add ItensDoMyData, i
%>
<input name="itens" type="checkbox" value="<% Response.Write ItensDoMyData %>"><label><% Response.Write ItensDoMyData %></label>
<%
End If
Next
End If
MyData.MoveNext
End If
%>
It's working, but i am not able to sort it, so the right output should be:
[ ] name 1 [ ] name 2 [ ] name 3 [ ] name 4
Is it possible to sort this kinda of output?
VBScript doesn't offer good sorting options however on anything remotely modern you will have access to the COM Visible classes provided by .NET, one of which is the
System.Collections.SortedList
class.Hence your code can look something more like this