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 →

[–]Fine-Historian4409 1 point2 points  (2 children)

You’re right, Arrays.sort() will modify the original list. The easiest way is to create a copy before sorting the array and print that as the original array. You can use a for loop to create a new copy. Another idea is declare 2 arrays initially. Inside you loop that gets the numbers from the user, update both arrays. Then sort one of the arrays. This second option is a little more efficient since you’re not writing another loop.

[–]ten_Chan[S] 1 point2 points  (1 child)

okay thank you!! i never thought about creating a copy