Return-Path: Delivered-To: apmail-excalibur-user-archive@www.apache.org Received: (qmail 36080 invoked from network); 3 Jun 2005 09:45:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Jun 2005 09:45:19 -0000 Received: (qmail 11279 invoked by uid 500); 3 Jun 2005 09:45:18 -0000 Delivered-To: apmail-excalibur-user-archive@excalibur.apache.org Received: (qmail 11167 invoked by uid 500); 3 Jun 2005 09:45:17 -0000 Mailing-List: contact user-help@excalibur.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: "Excalibur Users List" Reply-To: "Excalibur Users List" Delivered-To: mailing list user@excalibur.apache.org Received: (qmail 11132 invoked by uid 99); 3 Jun 2005 09:45:17 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of gcaeu-user@m.gmane.org designates 80.91.229.2 as permitted sender) Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 03 Jun 2005 02:45:15 -0700 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1De8fA-0005vE-92 for user@excalibur.apache.org; Fri, 03 Jun 2005 11:40:24 +0200 Received: from dialin-212-144-055-246.arcor-ip.net ([212.144.55.246]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 03 Jun 2005 11:40:24 +0200 Received: from listen by dialin-212-144-055-246.arcor-ip.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 03 Jun 2005 11:40:24 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: user@excalibur.apache.org From: Holger Klawitter Subject: Re: OT Friday - Random sorting Followup-To: gmane.comp.jakarta.tomcat.user Date: Fri, 03 Jun 2005 10:06:00 +0200 Lines: 62 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8Bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: dialin-212-144-055-246.arcor-ip.net User-Agent: KNode/0.8.2 Sender: news Cc: tomcat-user@jakarta.apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Mark Benussi wrote: > Hello. > > > > I am trying to write a comparator that randomly sorts a collection. > > > > I have something like this: > > > > new Comparator() { > > > > /** > > * @see java.util.Comparator#compare(java.lang.Object, > java.lang.Object) > > */ > > public int compare(Object object1, Object object2) { > > > > long time = new Date().getTime(); > > > > Random random1 = new Random(time); > > Integer x1 = new Integer(random1.nextInt()); > > random1.setSeed(++time); > > Integer x2 = new Integer(random1.nextInt()); > > > > return x1.compareTo(x2); > > } > > } > > > > But sadly to no avail. > > > > Has anyone done this before or have any suggestions. I'd just use java.util.Collections.shuffle(). -- With Kind Regards / Mit freundlichem Gru� Holger Klawitter (listen klawitter de) --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@excalibur.apache.org For additional commands, e-mail: user-help@excalibur.apache.org