Sorting words

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ahmed222too
    New Member
    • Sep 2007
    • 47

    Sorting words

    i make a text to list vb6 program that segments the text into words and add them in an access table ex. if the input (i go to school), the output will be:
    i
    go
    to
    school
    the output is in an access table
    my question is:
    i want to add the segmented words in the access table in their desending order
    i want the output to be
    to
    school
    i
    go
    i want the word to be added in its desending order in the table (i donot want to sort the column after adding words in their original places).
    my goal is to make a word frequancy program (in binary search) to be fast.
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    The easiest way to this is by using Order By DESC in sql statement.

    [CODE=sql]Select <ColumnName> From <TableName> Order By <ColumnName> DESC[/CODE]

    Comment

    • ahmed222too
      New Member
      • Sep 2007
      • 47

      #3
      Originally posted by lotus18
      The easiest way to this is by using Order By DESC in sql statement.

      [CODE=sql]Select <ColumnName> From <TableName> Order By <ColumnName> DESC[/CODE]
      iam sorry,
      but i want to add each word in its desending order in the table not to order the column after adding words in their original places

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        Then keep adding the records in the order you want.

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          I think you'll find that the whole concept of storing words in a specific sequence in a database is fundamentally flawed. It's best to think of the database as a big bucket into which you simply throw a bunch of things. The order in which they come back depends on what you do in your query.

          It may be possible to physically store the words in the sequence you want. But what happens if, for instance, you want to add more words later? You'd effectively have to create a whole new copy of the file with the new words inserted. And the order they come out would still depend on (A) the primary key if your table has one, and (B) the way you specify the query.

          If you ask about this in the Access forum, I'm sure someone there could explain it better than I can.

          That being said, if you really need to sort a bunch of words, one fairly simple method that has been used for many years is to add them all into a listbox control, with the Sorted property set to True. Of course, I don't know what version of VB you're using. This works up to VB6, at least.


          P.S. Perhaps a database isn't appropriate for your purposes. You might find it simpler to store your data in a text file.

          Comment

          • ahmed222too
            New Member
            • Sep 2007
            • 47

            #6
            Originally posted by debasisdas
            Then keep adding the records in the order you want.
            iam sorry
            i donot understand your reply
            could u clearify your words please
            thank u

            Comment

            • ahmed222too
              New Member
              • Sep 2007
              • 47

              #7
              Originally posted by Killer42
              I think you'll find that the whole concept of storing words in a specific sequence in a database is fundamentally flawed. It's best to think of the database as a big bucket into which you simply throw a bunch of things. The order in which they come back depends on what you do in your query.

              It may be possible to physically store the words in the sequence you want. But what happens if, for instance, you want to add more words later? You'd effectively have to create a whole new copy of the file with the new words inserted. And the order they come out would still depend on (A) the primary key if your table has one, and (B) the way you specify the query.

              If you ask about this in the Access forum, I'm sure someone there could explain it better than I can.

              That being said, if you really need to sort a bunch of words, one fairly simple method that has been used for many years is to add them all into a listbox control, with the Sorted property set to True. Of course, I don't know what version of VB you're using. This works up to VB6, at least.


              P.S. Perhaps a database isn't appropriate for your purposes. You might find it simpler to store your data in a text file.
              thank u for ur reply
              but i want to ask about the up limit for the list count in vb6 list box
              thank u

              Comment

              • QVeen72
                Recognized Expert Top Contributor
                • Oct 2006
                • 1445

                #8
                Hi,

                ListBox can contain maximum of 32766 items..

                Regards
                Veena

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  Originally posted by QVeen72
                  ListBox can contain maximum of 32766 items..
                  You may find that the practical limit is much lower, as things will slow down as you add more to the list. Try it, and see how it goes.

                  Comment

                  Working...