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.
Say i have this vector vector<PCB> Disks2;
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.