#include #include //for the i/o manipulator setw #include #include //for the algorithm sort using namespace std; //Create a new data type, named "month". struct month { string name; int length; }; int main() { month a[] { {"January", 31}, {"February", 28}, //non-leap {"March", 31}, {"April", 30}, {"May", 31}, {"June", 30}, {"July", 31}, {"August", 31}, {"September", 30}, {"October", 31}, {"November", 30}, {"December", 31} }; //Sort the array of structures into increasing numerical order. sort(begin(a), end(a), [](const month& a, const month& b) {return a.length < b.length;}); //make sure they were sorted correctly. for (const auto& value: a) { cout << left << setw(9) << value.name << " " << right << setw(2) << value.length << "\n"; } return EXIT_SUCCESS; }