Problem in order strings with letters and numbers

This is a discussion on Problem in order strings with letters and numbers within the C Programming forums, part of the General Programming Boards category; Hey ppl! i have strings in a program that are like this LL-NN-NN, NN-LL-NN and NN-NN-LL The final order that ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    4

    Problem in order strings with letters and numbers

    Hey ppl!

    i have strings in a program that are like this

    LL-NN-NN, NN-LL-NN and NN-NN-LL


    The final order that i want to show is LL-NN-NN, NN-NN-LL and finally NN-LL-NN


    how can i do this right ?
    can someone give me ideas ?

    Thanks

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    That's an interesting choice. In that case you'll want to write a sort function that first categorizes the string into one of those three types (say hello to isalpha() and isdigit()), then if it gets two of the same type, checks the actual numbers/letters themselves depending on how you want them sorted.

    Once you have that written, you can use it in your sort routine where you would have put < (or >, whichever you were using).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sum letters in written numbers from 1 to 2008
    By Desolation in forum C++ Programming
    Replies: 12
    Last Post: 04-26-2010, 02:18 PM
  2. converting letters into numbers.
    By xforevertink in forum C++ Programming
    Replies: 8
    Last Post: 07-20-2009, 12:12 AM
  3. Numbers to Letters
    By flip114 in forum C Programming
    Replies: 5
    Last Post: 09-24-2003, 03:18 AM
  4. Convert Phone Letters To Numbers
    By nicolobj in forum C Programming
    Replies: 4
    Last Post: 10-03-2002, 03:53 PM
  5. Transforming letters to numbers...
    By N8760 in forum C++ Programming
    Replies: 2
    Last Post: 12-23-2001, 02:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21