Please, can you put an example? I don't know how put the compareTo Method in my 
servlet.

Sérgio Costa <[EMAIL PROTECTED]> escribió:  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 = Calendar.getInstance();
> java.util.Calendar calTiempoFin = Calendar.getInstance();
> long intTiempoUtilizado;
> datTiempoInicio = 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 = 1; pasadas < astrName.length; pasadas++) {
> for (i = 0; i> intComparacion = astrName[i].compareTo(astrName[i+1]);
> if (intComparacion > 0) {
> strTemp = astrName[i];
> astrName[i] = astrName[i + 1];
> astrName[i + 1] = strTemp;
> dblIntensityTemp = adblIntensity1[i];
> adblIntensity1[i] = adblIntensity1[i + 1];
> adblIntensity1[i + 1] = dblIntensityTemp;
> dblIntensityTemp = adblIntensity2[i];
> adblIntensity2[i] = adblIntensity2[i + 1];
> adblIntensity2[i + 1] = dblIntensityTemp;
> dblBackgroundTemp = adblBackground1[i];
> adblBackground1[i] = adblBackground1[i + 1];
> adblBackground1[i + 1] = dblBackgroundTemp;
> dblBackgroundTemp = adblBackground2[i];
> adblBackground2[i] = adblBackground2[i + 1];
> adblBackground2[i + 1] = dblBackgroundTemp;
> } // end if (intComparacion > 0)
> } //end for i
> } //end for pasadas
>
> } // end if (astrName.length > 1)
>
> datTiempoFin = new java.util.Date();
> calTiempoFin.setTime(datTiempoFin );
>
> intTiempoUtilizado = Math.abs( (calTiempoFin.getTimeInMillis() -
> calTiempoInicio.getTimeInMillis()) / (1000) );
> System.out.println("(ProcessFile) Time = " + intTiempoUtilizado );
>
> ////////////////////////////////////////////////////////////////////////////////////////////////
>
>
> Can You help me?
>
>
>
> ---------------------------------
>
> LLama Gratis a cualquier PC del Mundo.
> Llamadas a fijos y móviles desde 1 céntimo por minuto.
> http://es.voice.yahoo.com
>


                
---------------------------------

LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com

Reply via email to