Is there a command to place variables in order?

Is there a command to place variables in order?
I mean like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <string>

using namespace std;

string ploeg_1; //namen ploegen
string ploeg_2;
string ploeg_3;
string ploeg_4;
//-----------------------------------------------------------------------------------------------------------
int score_1; //scores ploegen
int score_2;
int score_3;
int score_4;

int sb_1;// scorebord
int sb_2;
int sb_3;
int sb_4;

char x; //de - bij scores
//-----------------------------------------------------------------------------------------------------------
int scorecalc (int score1, int score2) { //score berekening 1
    if (score1 > score2)
    {
     return (3);
    }
    else if (score1 == score2)
    {
     return (1);
    }
    else
    {
     return (0);
    }
}
//-----------------------------------------------------------------------------------------------------------
int scorecalc2 (int score1, int score2) { //score berekening 2
        if (score1 < score2)
    {
     return (3);
    }
    else if (score1 == score2)
    {
     return (1);
    }
    else
    {
     return (0);
    }
}
//-----------------------------------------------------------------------------------------------------------
int main () {
    cout<< "Give name team 1: "; //ploegnamen invoeren
    getline (cin, ploeg_1);
    cout<< "Give name team 2: ";
    getline (cin, ploeg_2);
    cout<< "Give name team 3: ";
    getline (cin, ploeg_3);
    cout<< "Give name team 4: ";
    getline (cin, ploeg_4);
//-----------------------------------------------------------------------------------------------------------
    cout<< "\nDag 1:\n"<<ploeg_1<<" speelt tegen "<<ploeg_2<<".\n"<<ploeg_3<<" speelt tegen "<<ploeg_4<<"."; //speeldag uitleggen
    cout<< "\n\nWhat was the result of "<<ploeg_1<<" vs "<<ploeg_2<<"?\n"; //score invoegen
    cin>> score_1 >> x >> score_2;
    cout<< "\n\nWhat was the result of "<<ploeg_3<<" vs "<<ploeg_4<<"?\n";
    cin>> score_3 >> x >> score_4;
//-----------------------------------------------------------------------------------------------------------
sb_1 = scorecalc (score_1, score_2); //Scores BEREKENEN                                                                                                                                                                                                                        
sb_3 = scorecalc (score_3, score_4);
sb_2 = scorecalc2 (score_1, score_2);
sb_4 = scorecalc2 (score_3, score_4);
//-----------------------------------------------------------------------------------------------------------
     
cout<<"\n\n"<< ploeg_1 << " has "<< sb_1 <<" points.\n";
cout<< ploeg_2 << " has "<< sb_2 <<" points.\n";
cout<< ploeg_3 << " has "<< sb_3 <<" points.\n";
cout<< ploeg_4 << " has "<< sb_4 <<" points.\n\n\nMade by Xander D.\n\n";
    


system ("pause");
}


Dont mind the comments, they're in dutch.
i need what i typed underlined to be placed from highest variable (sb) to lowest. is that possible?

Thanks in advance,

Xander
Yes, you should look up arrays.
Just keep reading on in your book, arrays are a topic that's usually covered very early.

Edit:
I see you meant something else. The fact that you need to use arrays remains, though.
Use std::sort for sorting an array.

http://www.cplusplus.com/reference/algorithm/sort/

You will need to group your variables together into a class (which you should do anyway) in order to use sort.
Last edited on
Thanks,

and my "book" is this website"s tutorial xD

i must be VERY unlucky, because I made this program when i read up until the page before arrays -.-.

And how do you group variables into a class?
BTW, will it order the FULL sentences?
Topic archived. No new replies allowed.