Thread: sort 2D array

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    13

    sort 2D array

    I would like to sort a 2D array[3][5] of float in descending order based on the last 'cell' e.g. [0][4], [1][4], . . .

    Code:
       . . . 
    scorecard[i][j] = ttl_pts;    // load array
    
    for(u = 1; u < FLIGHT; ++u)
      for(v = FLIGHT; u < v; --v)
        if(scorecard[v-1][4] < scorecard[v][4])
           swap(scorecard[v-1], scorecard[v]);    // designate row? swap
    
    void swap (int * p, int * q)
    {
    	int temp;
    
    	temp = *p;
    	*p = *q;
    	*q = temp;
    }
    This method isn't working. Thanks in advance for any help.
    Keith
    Last edited by astro_not; 04-13-2003 at 12:15 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2D array of threads?
    By shorinhio in forum C Programming
    Replies: 2
    Last Post: 01-04-2007, 04:02 PM
  2. Dictionary into a 2d Char Array... Problems.
    By Muzzaro in forum C Programming
    Replies: 10
    Last Post: 12-02-2006, 12:34 PM
  3. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  4. Sorting an array of structures with sort()
    By rmullen3 in forum C++ Programming
    Replies: 3
    Last Post: 01-03-2003, 03:02 PM
  5. how to pass 2D array into function..?
    By IngramGc in forum C++ Programming
    Replies: 2
    Last Post: 10-21-2001, 08:41 AM