Sort array with multiple keys

This is a discussion on Sort array with multiple keys within the C Programming forums, part of the General Programming Boards category; Hi! Does someone know of a source code to sort an array of integers given multiple keys? Thanks!...

  1. #1
    Fab
    Fab is offline
    Registered User
    Join Date
    Sep 2005
    Posts
    8

    Sort array with multiple keys

    Hi!

    Does someone know of a source code to sort an array of integers given multiple keys?

    Thanks!

  2. #2
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    What do you mean by multiple keys? Give an example.

    Have you tried searching for what you are looking for?

  3. #3
    Fab
    Fab is offline
    Registered User
    Join Date
    Sep 2005
    Posts
    8
    What I mean by that is that I have an array of integer with 3 dimensions and I want to sort on say the second and 3rd

  4. #4
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Sorry, I still don't know what you mean. Can you give an example of a 3 dimensional array, and how you want to sort it?

    For example, if you declare int a[5][5][5];, that is a three dimensional array. Now let's imagine you fill it with random values, how do you want them sorted? Do you mean sorting them such that when you do this:
    Code:
    int x, y, z;
    for (x = 0; x < SIZE; x++)
        for (y = 0; y < SIZE; y++)
            for (z = 0; z < SIZE; z++)
                printf("%d %d %d = %d\n",x,y,z,a[x][y][z]);
    The values are printed in order, or something else?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 08:25 PM
  2. using qsort to sort an array of strings
    By bobthebullet990 in forum C Programming
    Replies: 6
    Last Post: 11-25-2005, 08:31 AM
  3. Array and sort help
    By Cstudent2121 in forum C Programming
    Replies: 7
    Last Post: 11-18-2005, 07:43 PM
  4. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 01:04 PM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 09:31 AM

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