From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12534 invoked from network); 19 Nov 2007 08:57:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 19 Nov 2007 08:57:51 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 42537 invoked from network); 19 Nov 2007 08:57:42 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 19 Nov 2007 08:57:42 -0000 Received: (qmail 5190 invoked by alias); 19 Nov 2007 08:57:28 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12219 Received: (qmail 5171 invoked from network); 19 Nov 2007 08:57:28 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 19 Nov 2007 08:57:28 -0000 Received: (qmail 41172 invoked from network); 19 Nov 2007 08:57:28 -0000 Received: from vms044pub.verizon.net (206.46.252.44) by a.mx.sunsite.dk with SMTP; 19 Nov 2007 08:57:22 -0000 Received: from torch.brasslantern.com ([71.121.18.67]) by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JRQ00EZXWVJC2NF@vms044.mailsrvcs.net> for zsh-users@sunsite.dk; Mon, 19 Nov 2007 02:57:20 -0600 (CST) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id lAJ8vI9h004164 for ; Mon, 19 Nov 2007 00:57:19 -0800 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id lAJ8vIeS004163 for zsh-users@sunsite.dk; Mon, 19 Nov 2007 00:57:18 -0800 Date: Mon, 19 Nov 2007 00:57:18 -0800 From: Bart Schaefer Subject: Re: Sorting file names randomly In-reply-to: <20071119042136.GA11967@scowler.net> To: Zsh Users Message-id: <071119005718.ZM4162@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <20050723194240.GA32416@DervishD> <20050723212657.GA744@DervishD> <1050724064415.ZM20425@candle.brasslantern.com> <20071119042136.GA11967@scowler.net> Comments: In reply to Clint Adams "Re: Sorting file names randomly" (Nov 18, 11:21pm) On Nov 18, 11:21pm, Clint Adams wrote: } Subject: Re: Sorting file names randomly } } On Sun, Jul 24, 2005 at 06:44:15AM +0000, Bart Schaefer wrote: } > for ((i=1; i <= $#; ++i)) { h[$i.$RANDOM]=$argv[i] } } } Is there any chance that prepending "$i." and hashing it will } decrease the randomness of the shuffle significantly? I no longer remember why I didn't just use h[$RANDOM] -- it may have been a typo. Looking back at the part of my message that you trimmed, I said: : The local RANDOM is there to force it to be zero-padded to 5 places, : so all the hash keys are the same length; probably not essential. But $i is not padded, so if that's prepended the hash keys aren't all the same length any more, which is why I wonder whether it's meant to be there at all. However, I suspect the randomness might be reduced for large numbers of arguments whether or not $i is prepended, because within each hash bucket the values are in a list in the order they were added to that bucket.