Sorting

This is a discussion on Sorting within the C Programming forums, part of the General Programming Boards category; I need to sort the following list: first by code, then by subcode and then by brandcode. code -> subcode ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    3

    Sorting

    I need to sort the following list: first by code, then by subcode and then by brandcode.

    code -> subcode -> brandcode (each code has a subcode and each subcode had a brandcode)

    Code:
    7366->65535->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    7366->65535->65535
    
    7366->65535->65535
    
    7379->65535->65535
    
    7366->65535->65535
    
    9113->65535->65535
    
    7379->65535->65535
    
    7315->5->65535
    
    7314->65535->65535
    
    7315->5->65535
    
    7314->65535->65535
    
    7379->65535->65535
    
    7314->65535->65535
    
    7314->65535->65535
    
    7314->65535->65535
    
    7311->65535->8
    
    7314->65535->65535
    
    7314->65535->65535
    
    7314->65535->65535
    
    7314->65535->65535
    
    7314->65535->65535
    
    7315->20->65535
    
    9126->65535->299
    
    7380->65535->65535
    
    7311->65535->35
    
    9126->65535->269
    
    7379->65535->65535
    
    7315->20->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    7323->65535->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    7366->65535->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    7314->65535->65535
    
    7315->5->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    7314->65535->65535
    
    7311->65535->35
    
    7366->65535->65535
    
    7314->65535->65535
    
    7315->5->65535
    
    7323->65535->65535
    
    7379->65535->65535
    
    7314->65535->65535
    
    7315->5->65535
    
    7315->5->65535
    
    7314->65535->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    7314->65535->65535
    
    7315->29->65535
    
    7314->65535->65535
    
    7315->29->65535
    
    7314->65535->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    7311->65535->8
    
    7379->65535->65535
    
    7379->65535->65535
    
    7328->65535->1005
    
    7366->65535->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    9126->65535->276
    
    7315->29->65535
    
    7317->65535->65535
    
    7379->65535->65535
    
    7377->65535->65535
    
    7311->65535->8
    
    7317->65535->65535
    
    7328->65535->1005
    
    7379->65535->65535
    
    7379->65535->65535
    
    7379->65535->65535
    
    7311->65535->35
    
    7311->65535->990
    
    7311->65535->8
    
    7311->65535->9
    
    7370->65535->65535
    
    7311->65535->8
    
    7315->29->65535
    
    7314->65535->65535
    
    9122->65535->65535
    
    7311->65535->35
    
    7311->65535->990
    
    7311->65535->8
    
    7321->65535->65535
    
    7311->65535->82
    
    7311->65535->10
    
    7311->65535->9
    
    7311->65535->11
    
    7311->65535->82
    
    7311->65535->35
    
    7311->65535->10
    
    7311->65535->10
    
    7311->65535->11
    
    7311->65535->35
    
    7311->65535->9
    
    7311->65535->10
    
    7311->65535->10
    
    7311->65535->9
    
    7311->65535->8
    
    7311->65535->82
    
    7311->65535->9
    
    7314->65535->65535
    
    7311->65535->11
    
    7311->65535->11
    
    7311->65535->10
    Sorting should be done in such a way that code is taken as primary key, subcode as secondary, brandcode as third key.

    The output should be as follows:

    Layer code Sub Code Brand Code
    7311 -> 65535 -> 8
    7311 65535 8
    7311 65535 8
    7311 65535 8
    7311 65535 8
    7311 65535 8
    7311 65535 8
    7311 65535 8
    7311 65535 8
    7311 65535 8
    7311 65535 8
    7311 65535 9
    7311 65535 9
    7311 65535 9
    7311 65535 9
    7311 65535 9
    7311 65535 9
    7311 65535 9
    7311 65535 9
    7311 65535 10
    7311 65535 10
    7311 65535 10
    7311 65535 10
    7311 65535 10
    7311 65535 10
    7311 65535 10
    7311 65535 10
    7311 65535 10
    7311 65535 10
    7311 65535 10
    7311 65535 11
    7311 65535 11
    7311 65535 11
    7311 65535 11
    7311 65535 11
    7311 65535 11
    7311 65535 11
    7311 65535 35
    7311 65535 35
    7311 65535 35
    7311 65535 35
    7311 65535 35
    7311 65535 35
    7311 65535 35
    7311 65535 35
    7311 65535 35
    7311 65535 82
    7311 65535 82
    7311 65535 82
    7311 65535 82
    7311 65535 82
    7311 65535 82
    7311 65535 82
    7311 65535 82
    7311 65535 82
    7311 65535 82
    7311 65535 82
    7311 65535 990
    7311 65535 990
    7311 65535 65535
    7312 65535 65535
    7313 65535 65535
    7314 65535 23
    7314 65535 88
    7314 65535 277
    7314 65535 676
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7314 65535 65535
    7315 5 65535
    7315 5 65535
    7315 5 65535
    7315 5 65535
    7315 5 65535
    7315 5 65535
    7315 20 65535
    7315 20 65535
    7315 29 65535
    7315 29 65535
    7315 29 65535
    7315 29 65535
    7315 29 65535
    7316 65535 65535
    7316 65535 65535
    7317 65535 65535
    7317 65535 65535
    7318 65535 65535
    7321 65535 65535
    7321 65535 65535
    7321 65535 65535
    7321 65535 65535
    7321 65535 65535
    7321 65535 65535
    7321 65535 65535
    7321 65535 65535
    7323 65535 65535
    7323 65535 65535
    7323 65535 65535
    7323 65535 65535
    7328 65535 1005
    7328 65535 1005
    7363 65535 65535
    7366 65535 65535
    7366 65535 65535
    7366 65535 65535
    7366 65535 65535
    7366 65535 65535
    7366 65535 65535
    7366 65535 65535
    7366 65535 65535
    7366 65535 65535
    7366 65535 65535
    7366 65535 65535
    7366 65535 65535
    7366 65535 65535
    7366 65535 65535
    7366 65535 65535
    7370 65535 65535
    7376 65535 65535
    7376 65535 65535
    7377 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7379 65535 65535
    7380 65535 65535
    7380 65535 65535
    7380 65535 65535
    7395 65535 65535
    7395 65535 65535
    9113 65535 65535
    9122 65535 65535
    9126 65535 269
    9126 65535 276
    9126 65535 276
    9126 65535 299


    Hope anyone can help me with this.



    Thanks

    jazz
    Last edited by jazzz; 05-24-2006 at 08:31 AM.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    My answer elseweb.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorting algorithms, worst-case input
    By Leftos in forum C++ Programming
    Replies: 17
    Last Post: 06-15-2009, 02:33 PM
  2. Need help with linked list sorting function
    By Jaggid1x in forum C Programming
    Replies: 6
    Last Post: 06-02-2009, 03:14 AM
  3. sorting structure members using pointers
    By robstr12 in forum C Programming
    Replies: 5
    Last Post: 07-25-2005, 06:50 PM
  4. Still Needing Help : selection sorting
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 10-14-2001, 09:41 PM
  5. selection sorting
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 10-13-2001, 09:05 PM

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