I had an earlier question about organizing some inputs by name, ID, and then Amount. Now that I have figured out how to get them organized, I need to have 3 outputs; the first by name, the second by ID, and the last by amount. can i use case and switch statements? Every time i tried to, all three outputs were by name.
this is what i have so far:
void GeneralSort(const int SortItem, const int count, CustomerProfile c[]) {
string tempname;
string tempid;
float tempamount;
for(int iteration = 1; iteration < count; iteration ++)
{
for(int n = 0; n < (count-iteration); n++)
{
if(c[n].CustomerName > c[n+1].CustomerName)
{
tempname = c[n].CustomerName;
c[n].CustomerName = c[n+1].CustomerName;
c[n+1].CustomerName = tempname;
}
if(c[n].CustomerId > c[n+1].CustomerId)
{
tempid = c[n].CustomerId;
c[n].CustomerId = c[n+1].CustomerId;
c[n+1].CustomerId = tempid;
}
if(c[n].AmountDue > c[n+1].AmountDue)
{
tempamount = c[n].AmountDue;
c[n].AmountDue = c[n+1].AmountDue;
c[n+1].AmountDue = tempamount
}
how do i get the rest of the data in, so it will have the 2nd output by ID, and the 3rd output by Amount. I think you can add switch statements but when I tired, all three outputs were by the first set, which is by name. any help is appreciated. im not expecting anyone to solve it all for me, just a tip to point me to the right direction.
output example:
//by name
name id amount
able b2 24
bob g3 68
carry a4 12
//by id
name id amount
carry a4 12
able b2 24
bob g3 68
//by amount
name id amount
carry a4 12
able b2 24
bob g3 68