Order a GameObject Array

i want to order a GameObject Array called with the GameObject.FindObjectsWithTag

i’m using this part of script:

	itemsCount = items.Length;
		itemsIdentity = new int[itemsCount];

		for (int i = 1; i <= itemsCount; i++) 
		{
			foreach (GameObject item in items) 
			{
				itemScript = item.GetComponent <ItemData> ();
			
				if (itemScript.ID == i) 
				{
					items.SetValue (item, itemScript.ID - 1);
					itemsIdentity [itemScript.ID - 1] = itemScript.ID;
				}
			}
		}

i don’t understand why, but with the item.SetValue (item, itemScript.ID - 1); line, in the Array will be only one of these GameObject.

any advice?

Take out the for loop its causing your itemScript.ID to get messed up (ie. the last run of the foreach loop they will all have the same ID.