I have a hashtable with a list of songs, which is in a random order (but with consecutive keys):
444, Slayer - Epedemic
445, Dragonforce - Fury of the Storm
446, Metallica - For Whom The Bell Tolls
This is written to a set of <option></option> tags for a select in a HTML page, as follows:
<option value="444">Slayer - Epedemic</option>
<option value="445">Dragonforce - Fury of the Storm</option>
<option value="446">Metallica - For Whom The Bell Tolls</option>
However, this isn't much use to users, as the songs are all over the place.
Dim trackList As String = ""
For i = 0 To trackNames.Count
If trackNames.Item(CStr(i)) <> "" Then trackList = trackList & "<option value=" & Chr(34) & CStr(i) & Chr(34) & IIf(i = activeTrack, " selected", "") & ">" & trackNames.Item(CStr(i)) & "</option>" & vbNewLine
Where trackNames is the hashtable. I also have another hashtable (called trackFiles) which has the same set of keys as trackNames, providing the file paths for the matching track names.
How can I change my code to list the track names in alphabetical order but keep the keys intact?