Re: [PATCH] Makes sort create random order

2005-02-01 Thread Paul Eggert
Frederik Eaton <[EMAIL PROTECTED]> writes: > $ sort -k 1,1R -k 3n > foo1 > foo2 > foo3 > bar1 > bar2 > bar3 > baz1 > baz2 > baz3 OK, now I see. Thanks. You want to sort via a random permutation of the keys, BUT you also want identical keys to sort together.

Re: [PATCH] Makes sort create random order

2005-01-31 Thread Frederik Eaton
On Mon, Jan 31, 2005 at 11:37:21AM -0800, Paul Eggert wrote: > Frederik Eaton <[EMAIL PROTECTED]> writes: > > > I've given many examples - can you give an example of a situation > > where people would put (a) differently-formatted numbers in a column > > of a file (how would they become differentl

Re: [PATCH] Makes sort create random order

2005-01-31 Thread Paul Eggert
Frederik Eaton <[EMAIL PROTECTED]> writes: > I've given many examples - can you give an example of a situation > where people would put (a) differently-formatted numbers in a column > of a file (how would they become differently-formatted?) and then sort > randomly based on their values, (b) insis

Re: [PATCH] Makes sort create random order

2005-01-30 Thread Frederik Eaton
> > seq feature for other things as well, I think, provided it was well > > implemented - e.g. 'jot' seems to seed it's RNG from epoch seconds, > > which is no good, microseconds would be better. The disadvantage is > > Yes, but there's two points here: > 1) There's generally a way to the user to

Re: [PATCH] Makes sort create random order

2005-01-30 Thread Felipe Kellermann
On Sun, 30 Jan 2005 12:10pm -0800, Frederik Eaton wrote: > seq feature for other things as well, I think, provided it was well > implemented - e.g. 'jot' seems to seed it's RNG from epoch seconds, > which is no good, microseconds would be better. The disadvantage is Yes, but there's two points h

Re: [PATCH] Makes sort create random order

2005-01-30 Thread Frederik Eaton
> Such a program could do things interesting like :- > > 1. Permute pseudo-randomly by default. > 2. Permute pseudo-randomly according to a seed specified on the >command line > 3. Generate the Nth permutation of its input, according to a >reproducible scheme > 4. Permute almost pseudo-ran

Re: [PATCH] Makes sort create random order

2005-01-30 Thread Frederik Eaton
> > A friend introduced me to that trick a few years ago and I have been > > using it ever since. $RANDOM is a ksh/bash specific feature. It is > > not POSIX but is widely available. > > I think my commentary on this is a bit off-topic here, but your message > reminds me of a dream I have for a

Re: [PATCH] Makes sort create random order

2005-01-30 Thread Felipe Kellermann
On Thu, 27 Jan 2005 10:21pm -0700, Bob Proulx wrote: > A friend introduced me to that trick a few years ago and I have been > using it ever since. $RANDOM is a ksh/bash specific feature. It is > not POSIX but is widely available. I think my commentary on this is a bit off-topic here, but your

Re: [PATCH] Makes sort create random order

2005-01-30 Thread Frederik Eaton
Oh, I forgot to respond. > This is not really what you are asking for. But when I need this > functionality I do it in the shell. Here is an example. I am not > particular about the exact type of non-ordered output. > > seq 1 20 > /tmp/datafile > > for i in $( | sort -n | sed 's/^[0-9

Re: [PATCH] Makes sort create random order

2005-01-29 Thread James Youngman
On Fri, Jan 28, 2005 at 11:36:41PM -0800, Paul Eggert wrote: > Let's put it a different way. Suppose we have a program that simply > generates as output a random permutation of its input lines. Would > that suffice? > > If so, perhaps we should simply create a new "permute" program rather > tha

Re: [PATCH] Makes sort create random order

2005-01-29 Thread Frederik Eaton
> > I think few people would care about this corner case. > > Maybe, maybe not; it's a bit hard to tell without knowing why > people need the option to "sort at random". I've given many examples - can you give an example of a situation where people would put (a) differently-formatted numbers in a

Re: [PATCH] Makes sort create random order

2005-01-28 Thread Paul Eggert
Frederik Eaton <[EMAIL PROTECTED]> writes: > I think few people would care about this corner case. Maybe, maybe not; it's a bit hard to tell without knowing why people need the option to "sort at random". Let's put it a different way. Suppose we have a program that simply generates as output a

Re: [PATCH] Makes sort create random order

2005-01-28 Thread Frederik Eaton
> > You don't get exactly the same behavior, e.g. the final distinction > > between 3 and 3.0 disappears, but I think this is OK. > > But this would cause the randomization option to not be orthogonal to > the rest of the options. The resulting behavior would be hard to > document, and it would b

Re: [PATCH] Makes sort create random order

2005-01-28 Thread Paul Eggert
Frederik Eaton <[EMAIL PROTECTED]> writes: > You don't get exactly the same behavior, e.g. the final distinction > between 3 and 3.0 disappears, but I think this is OK. But this would cause the randomization option to not be orthogonal to the rest of the options. The resulting behavior would be

Re: [PATCH] Makes sort create random order

2005-01-28 Thread Frederik Eaton
> Part of the problem -- as you'll see in the thread rooted at > > -- is that it's a bit tricky to define exactly what a random sort is. OK, that's a long thread. What is the question? E.g. a) how ties should be resolved The

Re: [PATCH] Makes sort create random order

2005-01-27 Thread Bob Proulx
Frederik Eaton wrote: > This is in response to a mail I found in the archive from "Wed, 25 Aug > 2004 16:14:15 +0200" that adds an -R option to sort randomly. I've > been seeking to add such functionality to sort for a while. This is not really what you are asking for. But when I need this functi

Re: [PATCH] Makes sort create random order

2005-01-27 Thread Paul Eggert
Frederik Eaton <[EMAIL PROTECTED]> writes: > 1. It looks like this isn't in 5.2.1 yet, has something been added to > cvs? Is something planned? Is somebody working on a patch? Not as far as I know. Part of the problem -- as you'll see in the thread rooted at

Re: [PATCH] Makes sort create random order

2005-01-27 Thread Frederik Eaton
This is in response to a mail I found in the archive from "Wed, 25 Aug 2004 16:14:15 +0200" that adds an -R option to sort randomly. I've been seeking to add such functionality to sort for a while. 1. It looks like this isn't in 5.2.1 yet, has something been added to cvs? Is something planned? Is

Re: [PATCH] Makes sort create random order

2004-09-11 Thread Paul Jarc
Paul Eggert <[EMAIL PROTECTED]> wrote: > You are asking for a program that randomly permutes its input. Then > let's design another program to do that, and not get bogged down > with how its features work together with "sort"'s existing zoo of > options. That might be the best thing: create a new

Re: [PATCH] Makes sort create random order

2004-09-11 Thread Paul Eggert
Thomas Habets <[EMAIL PROTECTED]> writes: > Once upon a midnight dreary, Paul Eggert pondered, weak and weary: >> > Or should a random permutation merge all equal values? >> Only if the ordinary sort would merge the equal values (i.e., if the >> -u option is specified). > > I mean merge them, then

Re: [PATCH] Makes sort create random order

2004-09-06 Thread Thomas Habets
Once upon a midnight dreary, Paul Eggert pondered, weak and weary: > > Or should a random permutation merge all equal values? > Only if the ordinary sort would merge the equal values (i.e., if the > -u option is specified). I mean merge them, then sort, then randomize, then split them. With no ra

Re: [PATCH] Makes sort create random order

2004-09-02 Thread Paul Eggert
Thomas Habets <[EMAIL PROTECTED]> writes: > They may be the same number, but they sure aren't treated as equal > (sort-order equal) by sort. sort -n gives "3 3.0 3.000" every time > here, no matter the input order. As does "3 03 3". That is because ties are broken at the end by a last-resort tex

Re: [PATCH] Makes sort create random order

2004-09-02 Thread Paul Eggert
[EMAIL PROTECTED] (Paul Jarc) writes: >> Sort of, but not quite. > > I couldn't find the "not quite" part of your explanation. Well, I tried. :-) >> "sort -rR" should output in the reverse order of "sort -R". > > Nit: they shouldn't expect that unless they also specify a seed. Yes, of course.

Re: [PATCH] Makes sort create random order

2004-09-02 Thread Thomas Habets
On Thursday 02 September 2004 08:47, you wrote: > > This means that two different files, that happen to sort to the same > > output, should give the same output when randomized with the same SEED. > > Is that right? [*] > and then sort as if that were the correct order. Part of the idea is > that

Re: [PATCH] Makes sort create random order

2004-09-02 Thread Paul Jarc
Paul Eggert <[EMAIL PROTECTED]> wrote: > Thomas Habets <[EMAIL PROTECTED]> writes: > >>> sort: Add an ordering option -R that causes 'sort' to sort according >>> to a random permutation of the correct sort order. >> >> This means that two different files, that happen to sort to the same outpu

Re: [PATCH] Makes sort create random order

2004-09-01 Thread Paul Eggert
Thomas Habets <[EMAIL PROTECTED]> writes: >> sort: Add an ordering option -R that causes 'sort' to sort according >> to a random permutation of the correct sort order. > > This means that two different files, that happen to sort to the same output, > should give the same output when randomiz

Re: [PATCH] Makes sort create random order

2004-08-28 Thread Thomas Habets
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Once upon a midnight dreary, Jim Meyering pondered, weak and weary: > sort: Add an ordering option -R that causes 'sort' to sort according > to a random permutation of the correct sort order. This means that two different files, that happen to s

Re: [PATCH] Makes sort create random order

2004-08-28 Thread Jim Meyering
Thanks for the offer. Here is the coreutils TODO item that suggests some design goals: sort: Add an ordering option -R that causes 'sort' to sort according to a random permutation of the correct sort order. Also, add an option --random-seed=SEED that causes 'sort' to use an arbitrary

Re: [PATCH] Makes sort create random order

2004-08-28 Thread Thomas Habets
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 (again, CC any replies. If this too much bother, I'll subscribe) Once upon a midnight dreary, Bob Proulx pondered, weak and weary: > > So, added -R, --random. > Normally to do this I usually use the nonstandard $RANDOM extension Ah. Nice. I hadn't tho

Re: [PATCH] Makes sort create random order

2004-08-28 Thread Bob Proulx
Thomas Habets wrote: > (if this email goes to a mailinglist then I'm not on it. Please CC > any replies if that is the case) > [...] > So, added -R, --random. I like the idea of providing a pseudo-randomizing, shuffling capability. I have actually wanted that myself on occasion. Normally to do t

[PATCH] Makes sort create random order

2004-08-25 Thread Thomas Habets
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 (if this email goes to a mailinglist then I'm not on it. Please CC any replies if that is the case) Yes, random order. That's not a bit oxymoronic. Why "sort randomly" you ask? Well, let's say you have a bunch of test-data, one per line (where "a bu