G
Guest
Hello,
Here is my problem:
I have an ArrayList with duplicate keys. I 'd like to preserve the original
order when sorting the list by using ArrayList.sort(comparer* c). However
when the comparer returns 0 (meaning the two objects are equal), the order of
the two objects are random or not preserved. I understand it's not a stable
sort. I also tried to return just -1 in my compare class when they are equal.
But this created a deadloop inside ArrayList.sort() for unknown reasons.
Does anyone know to how get around this?
Thanks.
David
Here is my problem:
I have an ArrayList with duplicate keys. I 'd like to preserve the original
order when sorting the list by using ArrayList.sort(comparer* c). However
when the comparer returns 0 (meaning the two objects are equal), the order of
the two objects are random or not preserved. I understand it's not a stable
sort. I also tried to return just -1 in my compare class when they are equal.
But this created a deadloop inside ArrayList.sort() for unknown reasons.
Does anyone know to how get around this?
Thanks.
David