public SortedList(IDictionary d, IComparer comparer)
: this(comparer, (d != null ? d.Count : 0))
{
if (d == null)
throw new ArgumentNullException(nameof(d), SR.ArgumentNull_Dictionary);
Contract.EndContractBlock();
d.Keys.CopyTo(_keys, 0);
d.Values.CopyTo(_values, 0);
// Array.Sort(Array keys, Array values, IComparer comparer) does not exist in System.Runtime contract v4.0.10.0.
// This works around that by sorting only on the keys and then assigning values accordingly.
Array.Sort(_keys, comparer);
for (int i = 0; i < _keys.Length; i++)
{
_values[i] = d[_keys[i]];
}
_size = d.Count;
}