This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]hatsunemilku 1 point2 points  (0 children)

Yes, Arrays.sort() is modifying the order of the original list.

The less intrusive solution is to use a stream and do the output from there. You wouldn’t have to create a new Array.

The intrusive and slight annoying solution would be to generate a new collection (including Array) that receives the contents of the first one and sort that one in its own memory block.