I am noticiing some inconsitencies but cant pin them down. Perhaps the
answer to this question can help.
If I have a vector of objects which on the server side I executed
Collections.sort(vector);
I then sent the vector over the network to the client (serialized I
assume).
Will the sort order be guaranteed to be the same in the Vector?
or should I always sort on the other end...?
thanks
Tim
Mike Schilling - 01 May 2006 07:31 GMT
>I am noticiing some inconsitencies but cant pin them down. Perhaps the
> answer to this question can help.
[quoted text clipped - 8 lines]
>
> or should I always sort on the other end...?
Serialization and deserialization will not change the order of objects in a
vector.
However, depending on what criteria you use to sort the items, perhaps they
should be in a different order in the two processes. For instance, if you
sort Objects by the value of their hashCode(), this will almost certainly
give different results. If you sort Strings and the two processes have
different default locales, that might result in differences as well.
Daniel Dyer - 01 May 2006 12:05 GMT
> I am noticiing some inconsitencies but cant pin them down. Perhaps the
> answer to this question can help.
[quoted text clipped - 8 lines]
>
> or should I always sort on the other end...?
A Vector is a List (java.util.List), which, unlike a Set, guarantees the
order of its elements. So if the order is not the same after
serialisation/deserialisation, then something is broken.
Dan.

Signature
Daniel Dyer
http://www.dandyer.co.uk