shuffle the lines of a large file
François Pinard
pinard at iro.umontreal.ca
Mon Mar 7 14:34:50 EST 2005
[Joerg Schuster]
> I am looking for a method to "shuffle" the lines of a large file.
If speed and space are not a concern, I would be tempted to presume that
this can be organised without too much difficulty. However, looking for
speed handling a big file, while keeping equiprobability of all possible
permutations, might be sensibly more difficult.
I vaguely remember having read something along these lines (not
shuffling as you mean it, but still, reorganising a lengthy file) in
Knuth's "Art of Computer Programming", in one of the exercises within
the chapter on Sorting methods (volume 3). That's long ago, but if I
remember well, Knuth did not consider this as an easy exercise.
--
François Pinard http://pinard.progiciels-bpi.ca
More information about the Python-list
mailing list