3 ms·
Arrays.sort() creates a full copy of the input data before sorting.
by Scaevolus 15y ago
Arrays.sort() creates a full copy of the input data before sorting.
- beagle3 15y agoIt 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.
- SeanLuke 15y agoI see nothing in the Java6 Arrays.java source code which would support this claim.
- Scaevolus 15y agoOops, I got Arrays.sort confused with Collections.sort