Thread: Sorting in alphabetical order

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    147

    Sorting in alphabetical order

    I have a linked list with nodes containing a string as its data member.

    Is there any way to load these string values into a binary search tree, where i can compare strings according to alphabetical order?

    the main thing is how do i sort according to alphabetical order, as in the past i have onli done sorting by number...
    Only by the cross are you saved...

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    115
    try using strcmp(member1->data,member2->data) and then perhaps swapping them.

    i would use strcmp, but maybe there are other ways.
    there are only 10 people in the world, those who know binary and those who dont

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    147
    i see, thanx, will try it...
    anybody know of any other method?
    Only by the cross are you saved...

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >anybody know of any other method?
    Since strcmp and strncmp work so nicely, we tend not to use any other methods.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 11-14-2008, 03:52 PM
  2. Putting a word in alphabetical order.
    By Brewer in forum C Programming
    Replies: 12
    Last Post: 12-16-2006, 05:11 PM
  3. Sorting in descending order
    By michael- in forum C Programming
    Replies: 3
    Last Post: 12-12-2005, 01:07 PM
  4. Replies: 30
    Last Post: 10-29-2005, 11:09 PM
  5. Sorting in Alphabetical order
    By Andre Santiago in forum C Programming
    Replies: 1
    Last Post: 12-13-2002, 06:14 PM