Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Sorting Alphabetically VB6

Options
  • 22-03-2004 7:11pm
    #1
    Registered Users Posts: 1,345 ✭✭✭


    Does anyone know a nice way of sorting an array alphabetically in VB6?

    Ive only had experience with bubble sorts and cant for the life of me figure out a way to sort alphabetically using a bubble sort without giving each letter of the alphabet a numeric value. I think my brains just gone for lunch :(


Comments

  • Moderators, Music Moderators Posts: 23,359 Mod ✭✭✭✭feylya


    Well you could use a bubble sort to sort the ascii value of the first letter of each array entry.


  • Registered Users Posts: 1,345 ✭✭✭Squall


    Hmmm hadnt thought of that (Should have been obvious). Thanks ill look into it.


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    afair in VB you can compare strings.


    like.

    if a$ < b$ then swap a$, b$

    or something like that.

    There is also a method for locale based sorting but I forget what it is.


  • Registered Users Posts: 629 ✭✭✭str8_away


    Why not use string Compare?

    You can set it to binary mode, which will compare ASII value.


    StrComp(string1, string2[, compare])

    compare:
    vbBinaryCompare 0 Perform a binary comparison.
    vbTextCompare 1 Perform a textual comparison


  • Closed Accounts Posts: 5,564 ✭✭✭Typedef


    Insertion sort algorithm, depending on the persistence of your data?

    If the data will persist then the overhead of sorting will be less costly then a straight bubble sort over lexical iterations... maybe.


    Somebody bring back Elvis.


  • Advertisement
  • Closed Accounts Posts: 329 ✭✭Walter Ego


    If your'e going to use ASCII values to sort, don't forget to convert all strings to UPPER or LOWER or the results won't be what you expected.


Advertisement