iNET Interactive - Online Advertising Agency
          
Go Back  Xtreme Visual Basic Talk > Other Languages > Miscellaneous Languages > sorting?


Reply
 
Thread Tools Display Modes
  #1  
Old 10-07-2003, 08:28 PM
antijock antijock is offline
Newcomer
 
Join Date: Oct 2003
Posts: 1
Default sorting?

ok, i have a 3 dimensional array. the program gets names and scores and stores them into the array accordingly. after that i want to have the students sorted by score, first or last name. after sorting have it print to the screen. right now it's only taking in 2 students just to make it easier on me. sounding like a assignment yet? well it is, I'm not denying it. lol. I have no clue as to how i would sort the info. any help would be much apprieciated. oh, if there is a more efficient way to do this would anyone plz let me know? thx again. hope i'm being clear...
this is all it is:


#include <iostream>
using namespace std;


int main()
{

char cSort; //choice of name or score sort
char cName [2] [2] [15]; //student 1 is in set 1, and 2 in 2
//first name in row 1, last in row 2
int iScore [2]; //stores scores

cout << "STUDENT #1\n";
cout << "Please enter first name: ";
cin >> cName [0] [0];
cout << "Please enter lastname: ";
cin >> cName [0] [1];
cout << "Score: ";
cin >> iScore[0];

cout << "\n\nSTUDENT #2\n";
cout << "Please enter first name: ";
cin >> cName [1] [0];
cout << "Please enter lastname: ";
cin >> cName [1] [1];
cout << "Score: ";
cin >> iScore [1];

cout << "\n\nWould u like to...\nSort by [F]irst name, [L]ast name, or [s]core: ";
cin >> cSort;

/*
if (cSort == 'f' || 'F')
//sort by first name
//print info to screen
else if (cSort == 'l' || 'L')
//sort by last name
//print info to screen
else
//sort by score
//print info to screen
*/
return 0;


}
Reply With Quote
  #2  
Old 10-10-2003, 08:57 PM
dr_moose dr_moose is offline
Centurion
 
Join Date: Sep 2003
Posts: 132
Default

The most efficient way of sorting stuff in an array (as far as I am aware) is called a "Quick Sort"

Source code for a quick sort can be found here http://users.sdsc.edu/~decastro/home...ts/datastruct/

It seems self-explanitory to me, but that's probably because I know what it's supposed to be doing, so if you need anything further, just say so.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting Bloodstein General 2 07-21-2003 05:58 PM
Sorting Squirm Tutors' Corner 15 06-06-2003 08:27 PM
Need Help Sorting NJDevils28 General 2 03-19-2003 11:42 AM
Sorting! Bytemaster General 3 02-17-2003 12:58 PM

Advertisement: