If I am using Arrays.sort with custom comparator over references of objects of my custom class, then is there anyway to replace the contents of the objects while sorting instead of just rearranging the references of objects

02-14-2010, 12:57 PM

JosAH

Quote:

Originally Posted by parthpatel

If I am using Arrays.sort with custom comparator over references of objects of my custom class, then is there anyway to replace the contents of the objects while sorting instead of just rearranging the references of objects

Why do you want to do that? On average (or always?) it is much cheaper to rearrange the references than to swap the content of all the objects.

kind regards,

Jos

02-14-2010, 01:26 PM

parthpatel

I want to keep the array spatially aligned because it contains more than 1000000 elements and normally when element i is under consideration, elements around i are used multiple times. So, if the array is aligned then it might improve the performance.