I'm looking for an algorithm that can randomly shuffle every line of an extremely large text file (aprox. 2 to 3 gigabytes). The obvious way is to load every line into a vector of strings and use something like std::random_shuffle(), but the problem is that it would take up an enormous amount of memory. So, what kind of algorithm can I use that's more memory friendly? Speed isn't a real big issue, but obviously I don't want to be waiting hours for it to finish =) Any ideas would be appreciated. Thanks.
Edit: forgot to mention, the file is pretty much in sorted order already. I'm trying to go from sorted, to randomly shuffled.