Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 95961 invoked from network); 26 Jun 2006 16:55:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Jun 2006 16:55:06 -0000 Received: (qmail 56672 invoked by uid 500); 26 Jun 2006 16:54:49 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 56610 invoked by uid 500); 26 Jun 2006 16:54:49 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 56571 invoked by uid 99); 26 Jun 2006 16:54:49 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Jun 2006 09:54:49 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of oscilate@gmail.com designates 64.233.162.204 as permitted sender) Received: from [64.233.162.204] (HELO nz-out-0102.google.com) (64.233.162.204) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Jun 2006 09:54:48 -0700 Received: by nz-out-0102.google.com with SMTP id z31so1393403nzd for ; Mon, 26 Jun 2006 09:54:28 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=ON8zkP1SSyh3p4HjAJs17dgfV2da93NHFPZpzPwJ1dwGmS+w9hUGtWXJUv8HcRIKBfGJgS15URuwZ2zZyOzAc8r9V6v9D7mzi8tNiwHMRhHIxjOFiBdZ67VLreYcS+4O8nA7+247DcskD1+pY1kKzkVhyDn+ta6MwDLKsK6mgCU= Received: by 10.36.141.20 with SMTP id o20mr8320927nzd; Mon, 26 Jun 2006 09:54:28 -0700 (PDT) Received: by 10.36.68.15 with HTTP; Mon, 26 Jun 2006 09:54:27 -0700 (PDT) Message-ID: <2b1dd0e10606260954q73d51ba0uc5392799013ee1b5@mail.gmail.com> Date: Mon, 26 Jun 2006 17:54:27 +0100 From: "=?ISO-8859-1?Q?S=E9rgio_Costa?=" To: "Tomcat Users List" Subject: Re: sort an array In-Reply-To: <20060626162622.31647.qmail@web25109.mail.ukl.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_11718_25334094.1151340867884" References: <20060626162622.31647.qmail@web25109.mail.ukl.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_11718_25334094.1151340867884 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Put them in a list and Collections.sort() them. All you'll need to do is create a Class with all those fields implementing Comparable, and implement the compareTo Method. hope it helps SC On 6/26/06, password password wrote: > > Hi, > > I have a servlet and in this servlet I have a problem when sort an > array. If in Tomcat 5.5.4 (on windows) the order is very fast (about 2 > seconds) , but in tomcat 5.5.9 is slower (about 25 seconds). I don't Know > why the same code has diferent time. > The code is the next. The array has 7000 elements. > > ///////////////////////////////////////////////////////////////////////= /////////////////////////////////// > java.util.Date datTiempoInicio, datTiempoFin; > java.util.Calendar calTiempoInicio =3D Calendar.getInstance(); > java.util.Calendar calTiempoFin =3D Calendar.getInstance(); > long intTiempoUtilizado; > datTiempoInicio =3D new java.util.Date(); > calTiempoInicio.setTime(datTiempoInicio ); > > if (astrName.length > 1) { > //ordenacion de los arrays: astrName[intFilaArray] > int i, pasadas; > String strTemp; > double dblIntensityTemp; > double dblBackgroundTemp; > int intComparacion; > for (pasadas =3D 1; pasadas < astrName.length; pasadas++) { > for (i =3D 0; i intComparacion =3D astrName[i].compareTo(astrName[i+1]); > if (intComparacion > 0) { > strTemp =3D astrName[i]; > astrName[i] =3D astrName[i + 1]; > astrName[i + 1] =3D strTemp; > dblIntensityTemp =3D adblIntensity1[i]; > adblIntensity1[i] =3D adblIntensity1[i + 1]; > adblIntensity1[i + 1] =3D dblIntensityTemp; > dblIntensityTemp =3D adblIntensity2[i]; > adblIntensity2[i] =3D adblIntensity2[i + 1]; > adblIntensity2[i + 1] =3D dblIntensityTemp; > dblBackgroundTemp =3D adblBackground1[i]; > adblBackground1[i] =3D adblBackground1[i + 1]; > adblBackground1[i + 1] =3D dblBackgroundTemp; > dblBackgroundTemp =3D adblBackground2[i]; > adblBackground2[i] =3D adblBackground2[i + 1]; > adblBackground2[i + 1] =3D dblBackgroundTemp; > } // end if (intComparacion > 0) > } //end for i > } //end for pasadas > > } // end if (astrName.length > 1) > > datTiempoFin =3D new java.util.Date(); > calTiempoFin.setTime(datTiempoFin ); > > intTiempoUtilizado =3D Math.abs( (calTiempoFin.getTimeInMillis() - > calTiempoInicio.getTimeInMillis()) / (1000) ); > System.out.println("(ProcessFile) Time =3D " + intTiempoUtilizado ); > > /////////////////////////////////////////////////////////////////////////= /////////////////////// > > > Can You help me? > > > > --------------------------------- > > LLama Gratis a cualquier PC del Mundo. > Llamadas a fijos y m=F3viles desde 1 c=E9ntimo por minuto. > http://es.voice.yahoo.com > ------=_Part_11718_25334094.1151340867884--