Easy
Re-sorting by a second key with std::sort
trades arrives already sorted by timestamp, ascending. The code re-sorts it by symbol so that each symbol's trades are contiguous, and a downstream step treats the last trade in each symbol's group as that symbol's most recent price. What does the C++ standard guarantee about the order of trades within one symbol's group after this std::sort?
main.cpp
struct Trade { std::string symbol; int64_t ts; double px; };
// trades is already sorted by ts ascending
std::sort(trades.begin(), trades.end(),
[](const Trade& a, const Trade& b) { return a.symbol < b.symbol; });
// Downstream: the last Trade in each symbol's group is taken as its latest price32 of 46 in Data Structures & Algorithms