List:MySQL and Java« Previous MessageNext Message »
From:Christopher Taylor Date:February 13 2003 12:43am
Subject:Re: order of rows
View as plain text  
Jeff,

Yeah, we do something similar in our applications.  The easiest way to sort
those items is to make a TreeMap with a Comparator that sorts your objects
with the proper key, and then call putAll() on the TreeMap passing your
existing HashMap as a parameter.

Or you could just blow off the HashMap altogether and just use the TreeMap
from the beginning... depending on the number of objects we're talking
about, the performance wouldn't be much different (AFAIK).

-Chris

----- Original Message -----
From: "Jeff Mathis" <jmathis@stripped>
To: <java@stripped>
Sent: Thursday, February 13, 2003 5:36 AM
Subject: Re: order of rows


> Jeff Mathis wrote:
> >
> never mind. as usual, I've not looked carefully at my own code.
>  I'm creating objects from the rows and putting those objects into a
> HashSet, and then calling iterator(), which we all know is not
> guaranteed to be in the order you think.
>
> jeff
>
> > hello all,
> >
> > I'm noticing that the order of rows returnd from a mysql query submitted
> > at the mysql prompt is not the same as the order returned from
> > submitting the same query through the api. Is there a reason for this?
> >
> > In particular, I can put an order by clause on the sql query that the
> > mysql pay attention to, but the api seems to ignore.
> >
> > jeff
> >
> > --
> > Jeff Mathis, Ph.D.                      505-995-1434
> > The Prediction Company                  jmathis@stripped
> > 525 Camino de los Marquez, Ste 6        http://www.predict.com
> > Santa Fe, NM 87505
> >
> > ---------------------------------------------------------------------
> > Before posting, please check:
> >    http://www.mysql.com/doc/         (the manual)
> >    http://lists.mysql.com/           (the list archive)
> >
> > To request this thread, e-mail <java-thread5041@stripped>
> > To unsubscribe, e-mail
<java-unsubscribe-jmathis=predict.com@stripped>
>
> --
> Jeff Mathis, Ph.D. 505-995-1434
> The Prediction Company jmathis@stripped
> 525 Camino de los Marquez, Ste 6 http://www.predict.com
> Santa Fe, NM 87505
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/doc/         (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <java-thread5042@stripped>
> To unsubscribe, e-mail
<java-unsubscribe-cstaylor=nanshu.com@stripped>
>
>

Thread
order of rowsJeff Mathis12 Feb
  • Re: order of rowsJeff Mathis12 Feb
  • Re: order of rowsChristopher Taylor13 Feb