Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Sorting Alphabetically VB6

  • 22-03-2004 07:11PM
    #1
    Registered Users, Registered Users 2 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,363 Mod ✭✭✭✭feylya


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


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


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


  • Registered Users, Registered Users 2 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, Registered Users 2 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,563 ✭✭✭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