I have two Arrays with the same lenght(e.g. 3), one Array is a String Array and the other is an int Array. The int Array is sorted and gets a new index starting with the lowest value, how can I get the old index back(without destroying the new index) and compare it with the index of the string Array?
var stringID_1 = PlayerPrefs.GetString("String_1") // same for String_2 and _3
var intID_1 = PlayerPrefs.GetInt("Int_1") // same for Int2 and _3
//
function Update()
{
var stringArray = new Array(
stringID_1,
stringID_2,
stringID_3
);
Debug.Log(stringArray);
//
var intArray = new Array(
intID_1,
intID_2,
intID_3
);
Debug.Log(intArray);
//
intArray.Sort();
Debug.Log(intArray)
//
var newIndex = new Array(intArray);
//
Debug.Log("HighestInt" +newIndex[2]);
Debug.Log("LowestInt" +newIndex[0]);
//
//Here I want to combine for e.g intArray[1] and stringArray[1] ,
//but the Index for the intArray has changed after
//var newIndex = new Array(intArray);
//
Edit: Changed the Question title, it was misleading.
In general I want to print stringID_1 + intID_1 , but not all IDs are needed, only the Highest intID and the lowest this is why Iam sorting the intArray and pass it to a new Array. But after sorting the Indexes of the string_IDs and intID`s are not longer matching
Are you trying to assign an int to a string and vice-versa? In that case, then you should use a hashtable or dictionary.
– Peter_GLooks like a Hashtable is the the right way, I searched here, the script reference and in the wiki but I cant find the information how to sort a Hashtable. Sort is not a member of Hashtable, and passing the Hashtable to an Array and sort that Array is not working.
– GameGuy