Friday, February 24, 2012

[zkqiglua] Numerically and lexicographically ordered

The following sequence remains properly numerically ordered even after lexicographic sorting.

0 1 2 3 4 5 6 7 8 900 901 902 903 ... 995 996 997 998 9990000 9990001 9990002 ... 9999997 9999998 999999900000000

The number of zeroes at the end goes up by powers of 2.

You don't have to pick a width in advance like printf %08d, and the sequence is unlimited.

It may be useful for automatically generated file names such as for the "split" program, perhaps in a different base.

No comments :