Hacker News new | ask | show | jobs
by Scaevolus 5272 days ago
Arrays.sort() creates a full copy of the input data before sorting.
2 comments

It was copying more, or for some reason expending from ints to Integers -- it multiplied the required memory by 12.

I don't have access to that source code anymore, and I don't remember what exactly I used, but -- given that I had to implement my own data structure over mmap -- it was an array of int, which needed sorting through a comparator class I supplied. That comparator looked up the structs corresponding to ints, and compared them. Perhaps it was just crazily instantiating the comparator class or something.

I see nothing in the Java6 Arrays.java source code which would support this claim.
Oops, I got Arrays.sort confused with Collections.sort