#!/usr/bin/env python
+"""Generate random (or ordered) data for sorting.
+
+Output format:
+
+ # <N>
+ <point 1>
+ <point 2>
+ <point 3>
+ ...
+ <point N>
+"""
+
+import optparse
import random
import sys
-N = int(sys.argv[1])
+p = optparse.OptionParser(usage='%prog [options] N_POINTS', epilog=__doc__)
+p.add_option('-o', '--ordered', dest='shuffle', default=True,
+ action='store_false', help="Don't shuffle the output data.")
+
+options,args = p.parse_args()
+
+N = int(args[0])
data = range(N)
-random.shuffle(data)
+
+if options.shuffle:
+ random.shuffle(data)
print '# %d' % N
print '\n'.join([str(x) for x in data])