- Home /
system.array command processes unspecified/difrent array
i do something with Array1 and it also changes Array2:
var distances :float[] = new float[nodes.length]; //Array1
var distances_sort :float[] = new float[nodes.length]; //Array2
then:
distances_sort = distances;
System.Array.Sort(distances_sort);
And then distances[] has been sorted also. I wanted to make a duplicate of the array that is sorted-by-ascending so I can tell what the 5 largest numbers are in it, whilst keeping the order in the original array.
How do I change 1 array only and keep the original in .js?
Thank You!
Answer by MountDoomTeam · Mar 15, 2013 at 12:20 AM
okay I found a lot of answers on: http://answers.unity3d.com/questions/256522/setting-arrays-equal-to-each-other-issue.html
the working solution was simply to fill the array2 at the same time as the array1 rather than copying one to the other afterwards.
Your answer
![](https://koobas.hobune.stream/wayback/20220613094425im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to Clone Array1 into Array2 in Unity? Using JavaScript. 0 Answers
How to set color to gameObject respective to below coding? 2 Answers
Ways to minimize Object.stelemref() calls (low level) 1 Answer
JesseEtzler's RPG Talent System in C# 1 Answer
Dungeon crawler problem(getting transform data from an array) 1 Answer