I have these 2 arrays. Values in Array 1 are in the correct order. Values in the Array 2 are in incorrect order. What I need to do is loop through both array and sort the IPs so that the same IPs are in the same index in the array 2.
I was trying nested loops .
I was trying the nested loops below but no luck.
I have also tried nested ForEach but instead of getting the cross section, I get everything.
I have checked the compare-object cmdlet but it does not really seem useful in this case.
Any ideas?
$arrayOfItemsToCompare | ForEach-Object { if ($array -contains $) { Write-Host $ } }
Array 1: 192.168.3.1 192.168.1.1 10.49.50.254 0.0.0.0 90.183.197.126 194.228.115.69 90.182.79.231 90.182.78.193 194.228.115.67 194.228.115.66 194.228.190.115 194.228.92.85 172.253.50.253 108.170.238.231 216.58.201.68 Array 2: DestinationIP AverageLatency Success ------------- -------------- ------- 192.168.3.1 0 100 192.168.1.1 0 100 194.228.115.69 16.4 100 90.183.197.126 17 100 90.182.78.193 16.8 100 194.228.115.67 16.8 100 194.228.115.66 17.4 100 194.228.190.115 17.8 100 172.253.50.253 17.8 100 194.228.92.85 18.4 100 108.170.238.231 18 100 216.58.201.68 17.6 100 10.49.50.254 0 0 90.182.79.231 0 0