Link to home
Start Free TrialLog in
Avatar of baseballfan45
baseballfan45

asked on

copy an array

I am passing an object array into a function and I want to return a sorted copy of the array without altering the original.  I dont want to copy the actual objects in the array, I just need two arrays pointing to the same objects, just in different orders.  So the original array will remain unchanged, but the sorted array will point to the same objects at the one I passed into the function, but it will point to them in a sorted manner.  How do I go about creating and assinging the array which will hold the sorted order?  I already have an effective sorting algorithm, I just need to figure out how to define and assign the sorted array such that it will point to the same objects, yet when I run the sorting process, it will not alter the original array as well.  Thanks
ASKER CERTIFIED SOLUTION
Avatar of ilmt
ilmt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of baseballfan45
baseballfan45

ASKER

i tried that and that still passes back the unsorted array though for some reason.
never mind...that worked