Open the file to be indexed, Deturmine the number of records... Create an array with that many records, read the data from the specified field into the array, run the sort, write the sort returns to the index file.
So if i want to sort say a three item file with the following:
ID UserName UserAccess
1 Administrator Administrator
2 John Doe User
3 Jane Doe User
and wanted to create an index of the 'UserName' field using the something like the below....:
'###Code Retrieved from http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/c185b322-d7de-41e6-8617-922a4323c309 Not my code!!!###'
Sub SortData()
Dim gap As Integer, doneFlag As Boolean
Dim temp As String
gap = CInt(Int(numParts / 2))
'Set the gap to half the total size
Do While gap >= 1
'Execute the loop until the gap has been eliminated
For index As Integer = 0 To numParts - 1 - gap
'For items from the start up to the end of the gap,
If part(index) > part(index + gap) Then
'If this item and the item that is gap distance away are out of order,
temp = part(index)
part(index) = part(index + gap)
part(index + gap) = temp
'swap them, and
doneFlag = False
'indicate that we needed to swap at least on item, so another pass will be needed
End If
Next
Loop Until doneFlag = True
'When that pass executes without a swap, then
gap = CInt(Int(gap / 2))
' halve the gap
Loop
' and repeat (until there is no gap)
End Sub
Since i have literally no clue about getting that to work maybe some one would have some advice on what i need to read on to learn more about the shell sort, or anything to better explain what is going on in the glob of confusion that is happening there above???
everything i have come up with is so darned cryptic, it seems like people don't want others to know what is going on...
any help would alleviate my confusion greatly appreciated
Jesse Fender
This post has been edited by chuckjessup: 22 February 2011 - 01:02 AM

New Topic/Question
Reply



MultiQuote


|