# My arrays keep copying each other!

**URL:** <https://forum.kirupa.com/t/my-arrays-keep-copying-each-other/113525>\
**Category:** Uncategorized\
**Created:** [June 18, 2004, 8:19pm UTC](https://forum.kirupa.com/t/my-arrays-keep-copying-each-other/113525 "2004-06-18T20:19:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Boondogger](https://avatars.discourse-cdn.com/v4/letter/b/e274bd/32.png) [@Boondogger](https://forum.kirupa.com/u/Boondogger)\
**Post date:** [June 18, 2004, 8:19pm UTC](https://forum.kirupa.com/t/my-arrays-keep-copying-each-other/113525/1 "2004-06-18T20:19:56Z")

</div>

This is probably something really simple but I have this multi-dimensional array which holds vital data. At one point in my program I need to copy the array so that I can sort it numerically and display the data, without permanently altering the original array order. I thought okay, create a new array and copy the original array data into it. Here is the code:

MyArrayCopy = new Array();  
MyArrayCopy = MyArray;  
MyArrayCopy.sort(function (b,a){return b [3] - a [3]});  
MyArrayCopy.reverse();

Then I display what’s in MyArrayCopy.

Bizarrely, when I go back to another part of the program I find that the data in the original MyArray has been changed too. Can anyone explain this and suggest how I can get round it?

Boondogger
