I'm trying to find the closest group of elements that qualify in sequence compared to an existing dictionary. The goal is to take first group of elements that contain string values in a specific order. In my case, I may have a larger list, that looks kinda like this:
{1, "ISO"}
{2, "AEA"}
...
{256, "OI"}
...
{302, "OI"}
{303, "N2"}
{304, "N2.5"}
...
{400, "N2"}
The objective of this is to find key value pairs that contain values in a specific order, and return the LOWEST key from those key value pairs. To get what I felt was halfway there, I extracted all of the possibilities of pairs that contain the values "OI," "N2," and "N2.5."
Suppose from this I have a Dictionary, which is built like this:
Dictionary map = new Dictionary<int,string>();
map.Add(new KeyValuePair<int, string>(256, "OI");
map.Add(new KeyValuePair<int, string>(302, "OI");
map.Add(new KeyValuePair<int, string>(303, "N2");
map.Add(new KeyValuePair<int, string>(304, "N2.5");
map.Add(new KeyValuePair<int, string>(400, "N2");
I'd like to pull out the elements from this Dictionary whose key is closest to the other, so that I get a list in ascending order, like the KeyValuePairs containing 302, 303, and 304 as the keys. What's the best way to go about this?