#include <algorithm>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
// our "input" stream:
std::istringstream in(
R"(CallStarted_Cap900 10.160.159.37 32514 unid to 10.9.11.66 32740 RABIA-TUJIMET-CERYAN at 2015 04 21 16 33 54 921.waa_end
CallStartedAck_Cap900 10.160.159.37 32514 unid to 10.9.11.66 32740 RABIA-TUJIMET-CERYAN at 2015 04 21 16 33 54 921.waa_end
CallStarted_Cap900 10.9.11.61 32572 3051905 to 10.9.11.18 39994 79970056 at 2015 04 21 16 33 54 994.waa_end
CallStartedAck_Cap900 10.9.11.61 32572 3051905 to 10.9.11.18 39994 79970056 at 2015 04 21 16 33 54 994.waa_end
CallStarted_Cap900 10.160.167.34 32514 unid to 10.9.11.61 32580 RGorusme at 2015 04 21 16 33 55 035.waa_end
CallStartedAck_Cap900 10.160.167.34 32514 unid to 10.9.11.61 32580 RGorusme at 2015 04 21 16 33 55 035.waa_end
)");
bool less_than(const std::string& a, const std::string& b)
{
// error checking should be done here.
return a.substr(a.find(' ')) < b.substr(b.find(' '));
}
bool equal(const std::string& a, const std::string& b)
{
// error checking should be done here.
return a.substr(a.find(' ')) == b.substr(b.find(' '));
}
int main()
{
std::ostream& out = std::cout;
std::string line;
std::vector<std::string> lines;
while (getline(in, line))
lines.push_back(line);
std::sort(lines.begin(), lines.end(), less_than);
bool previous_output = false;
for (std::size_t i = 0, j = 0; i != lines.size(); i = j)
{
if (previous_output)
out << std::string(40, '-') << '\n';
while (j != lines.size() && equal(lines[i], lines[j]))
out << lines[j++] << '\n';
previous_output = true;
}
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KCi8vIG91ciAiaW5wdXQiIHN0cmVhbToKc3RkOjppc3RyaW5nc3RyZWFtIGluKApSIihDYWxsU3RhcnRlZF9DYXA5MDAgMTAuMTYwL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