We help IT Professionals succeed at work.

sorting files

Sycon1
Sycon1 asked
on
250 Views
Last Modified: 2010-04-17
i am doing a programme where i have to update file names from a user hardrive to a web server using a vb application. The problem is before I upload the files I need to sort the files uging vb them before the 'insert' statement executes. Any sugestions. Thanks
Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Commented:
Sycon1,
    And here is some sample code for you to use

http://www.freevbcode.com/ShowCode.Asp?ID=965

Dang123
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Here's bubblesort in vb

Public Sub BubbleSort(vntelts)
        Dim i, j
        Dim tempelt
       
        blnStop = False
        Do Until blnStop = True
            blnStop = True
            For i = 0 To UBound(vntelts)
                If i <> UBound(vntelts) Then
                    If getSortKey(vntelts(i)) > getSortKey(vntelts(i + 1)) Then
                        Set tempelt = vntelts(i)
                        Set vntelts(i) = vntelts(i + 1)
                        Set vntelts(i + 1) = tempelt
                        blnStop = False
                    End If
                End If
            Next
        Loop
End Sub

Private Sub getSortKey(elt As Variant)
    'TODO: Customize to return the sort key for your data.
    getSortKey = cstr(elt)
End Sub

Commented:
LoL, that bubble sort is almost a complete repost of my code, accept you didn't do any sorting code.... and your code doesn't take into account if the to "keys" are identical....
That's fair. To be honest, I didn't read Kavar's post in detail - I had a Bubblesort implemention handy and thought it might be useful.
I believe if the keys are the same, it leaves the elements adjacent and in the same order as the input array.
Out of curiosity, what's wrong with VBs standard string comparison such that you feel the need to write AlphaSort? That is, how is it different than:
Function AlphaSort(comp1,comp2)
  AlphaSort = Iif(comp1 < comp2, comp1, comp2)
End function

Commented:
to tell you the truth, I was unaware of the actual functionality of the string support
is it ASCII order or is it 7bit ordering or what...??

I am guessing since you bring it up it works fine? (would have been nice to know 400 scripts ago)

Is the behavior the same between vba, vb and vbscript?

oh yeah, the equals thing, well apparently I DIDN'T READ your code closely enough,
in your case the string only moves if it is Greater, unlike my *ahem* little more clunkey code moves the second up if it is found to be first in the sort order.  
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Commented:
Very Nice to Know :)

Commented:
question looks abandoned :(
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.