Is there a way to sort a vector with a class that has an int variable? I want to have my vector sorted and printed in console. I want to be able to sort the vectors.
Say i create a bunch of vectors here on user input vector<PCB> Disks2[DiskDevices];
Basically if i choose vector<PCB> Disks2[1];
itll sort 1 if i choose vector<PCB> Disks2[2];
itll sort 2 based on the Cylinder in the class.
And i have this class
class PCB
{
public:
void setPID (int a)
{
PID = a;
}
int retrievePID()
{
return PID;
}
void setFilename (string input)
{
Filename = input;
}
string retrieveFilename()
{
return Filename;
}
void setMemstart (int a)
{
Memstart = a;
}
int retrieveMemstart()
{
return Memstart;
}
void setRW (char a)
{
rw = a;
}
char retrieveRW()
{
return rw;
}
void setFilelength (int input)
{
Filelength = input;
}
int retrieveFilelength()
{
return Filelength;
}
int retrieveCylinder()
{
return Cylinder;
}
void setCylinder (int a)
{
Cylinder = a;
}
private:
int PID;
string Filename;
int Memstart;
char rw;
int Filelength;
int Cylinder;
};
How can i sort that vector based on the Cylinder int? I want the Vector to organize the order of the information based on Cylinder? Is this possible? I cant figure it out.