How to create a custom sort for strings based on a logical order?

All good, just having trouble finding documentation on that type of declaration. Appreciate the help!

std::pair<x,y> does not have names, it is a pair object with two types, in the case of my example it contains a String and an int. You can access the two values in the pair in a variety of ways, using std::get, or pair.first, pair.second, or, as in this case, I used a structured binding, that the [quality, id] part.

that is called structured binding it will take the individual components of a returned value, and assign give them a local alias that you can use like a variable.

For what do you need the index for? if you do need the index, then use a standard for loop…
(again, this is untested code, just typed in here)

for (const auto elementIndex { 0 }; elementIndex < allQualities.size(); ++elementIndex)
    const auto [quality, id] { allQualities [ elementIndex ] };
    if (availableQaulities .contains(quality))
        comboBox.addItem(quality, id);
1 Like