# QuestionKey Value Pair Compare based on Value.

#### KINGKODA

##### New member
Hello,

I've got a sortedDict = new SortedDictionary<double,double>();

And I'm trying to get the Key of the Value that is greater than the three Values above and three Values below but I don't know how.

sortedDict looks like this:
{
1.10 , 20
1.09 , 75
1.08 , 32
1.07 , 440 ------> This Value is greater than the Values of 3keys above and below
1.06 , 200
1.05 , 160
1.04 , 130
1.03 , 250 ------> This Value is greater than the Values of 3keys above and below
1.02 , 62
1.01 , 73
1.00 , 15
}

Output: (How do I get this?)
1.07
1.03

Any help will be greatly appreciated.

Last edited:
The first thing to do with programming problems like this is to forget that they are programming problems. Consider them manual problems, to be presented and solved using pen and paper. Assume that you need to provide a set of instructions that anyone can follow to get the correct result. What steps would those instructions provide? Note that humans usually employ rather fuzzy logic but the steps you need to describe must be formalised and each one as basic as possible. Get to writing that set of instructions.

Once you get to the point that you can follow those instructions to the letter, doing everything specified and nothing that isn't, and get the correct result for any input set, you have got yourself an algorithm. Only once you have a working algorithm should you even consider writing any code. The code you write should implement the algorithm to the letter. If the algorithm works then any code that implements it correctly will also work.

If you get to the point where you believe that you have a working algorithm and you believe that you have code that implements that algorithm but the code does not produce the expected result, that is when you should post a question. Most people don't nearly exhaust their own capabilities before asking for help. The fact that you don't even know what the code you want to write has to do is an indication that you haven't either. Pretty much anyone could solve this problem manually so that means that pretty much anyone can come up with an algorithm; no programming experience required. Different people will produce algorithms of different quality but anyone can make an attempt. I suggest that you make an attempt and post back if and when you strike an actual issue. I'll be first in line to help at that point.

Thank you for your response, I got help from another forum and now everything is working perfectly.

Replies
6
Views
1K
Replies
4
Views
3K
Replies
4
Views
2K
Replies
5
Views
2K
Replies
8
Views
1K