Thread: sorting arrays

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2007
    Location
    Florida
    Posts
    45

    sorting arrays

    hello everyone,

    I was wondering if there is way to sort two different arrays of different data types without struct's.
    For example lets say you have an array of doubles that represent rainfall for each month of the year. [0] representing January's rainfall amount, etc... Then I have an array of char's with the names of the months. [0] representing "January". Now I sort the rainfall in descending order, how do I get the char array to stay in sync with the rainfall array. I was planning on using a selection method to sort the rainfall amounts, but I can't pass it a double array and a char array.
    I know I could create another array of int's and use a selection method to sort rainfall and int's 1-12 to represent the months. Then I could pass this to a switch statement or loop to display the months rainfall. This way seems to show my inexperience. I know there has to be a way to sort them without any special libs.

    thanks for your time,
    Brad
    Last edited by bradleyd; 06-17-2008 at 12:54 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 06-11-2009, 11:27 AM
  2. Sorting Arrays
    By DaniiChris in forum C Programming
    Replies: 11
    Last Post: 08-03-2008, 08:23 PM
  3. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  4. Replies: 2
    Last Post: 02-23-2004, 06:34 AM
  5. sorting arrays
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 10-13-2001, 05:39 PM