I have two collections:
One the one hand, a dictionary containing Products with Id's and on the other hand, a list of Id's containing the order in which they should be ordered.
The dictionary contains objects like this:
The sorting list is just a simply int array
{1, 3, 2, 5, 7...}
To sort the dictionary using the orderArray, I'm using the following code:
foreach (var index in orderList)
{
dictionary.Value.Sort((first, second) =>
{
var x = first["ID"].Equals(index).CompareTo(second["ID"].Equals(index));
return x;
});
}
This code works fine for dictionaries up to and including 16 items, but as soon as a larger dictionary is passed in, the sorting algorithm breaks. What could be the cause of this?