GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 10-Nov-2003, 15:26
gotnospoon gotnospoon is offline
New Member
 
Join Date: Nov 2003
Posts: 1
gotnospoon is an unknown quantity at this point

vector sorting


Hi, my name is Travis and I'm doing a project at ITT-Tech and I need help with this code please. I am trying to sort my database in alphabetical order using a vector with this code but it wont sort in any order...
.cpp file
CPP / C++ / C Code:
//----------top of the .cpp file-------------
#include <iostream>
#include <vector>
#include <string>
#include "StuRec.h"

using namespace std;

StudentRec::StudentRec(string studentName, string studentID)
{
	stuName = studentName;
	stuID = studentID;
}
//-----------code i need help with--------------
void SelectionSort (vector<StudentRec> & stuVec)
{
	int count = stuVec.size();
	int outer, inner;
	string lowest;
	int LowestPos;
	for (outer = 0; outer < count; outer++)
	{
		lowest = stuVec[outer].GetName();
		LowestPos = outer;
		for (inner = outer + 1;inner < count; inner++)
		{
			if (lowest > stuVec[inner].GetName())
				{
				lowest = stuVec[inner].GetName();
					stuVec[LowestPos].GetName() = inner;
			}
		}
		stuVec[LowestPos] = stuVec[outer];
		stuVec[outer].GetName() = lowest;
	}
}
Now I realize that I am dealing with int and string but I'm not sure how to get it to sort. The function calls and the vector names are all correct its just I need to know how to get it to sort.
Now I type in the student name and student Id but I just need it to sort with just the name
Thank you.
 
 

Recent GIDBlogDeveloping GUIs with wxPython (Part 3) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:36.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.