Programming Tips - C++: How to randomize the order (shuffle) an std::vector of std::string's

Date: 2009Oct11 Update: 2025oct20 Language: C++ Keywords: card game Q. C++: How to randomize the order (shuffle) an std::vector of std::string's A. Here's a function that does it:
#include <string> #include <vector> #include <algorithm> typedef std::vector<std::string> LINES; void ShuffleVectorOfStdString(LINES &lines) { srand(time(NULL)); random_shuffle(lines.begin(), lines.end()); }