"Grouping" dictionary by value

Posted by user1260827 on Stack Overflow See other posts from Stack Overflow or by user1260827
Published on 2012-11-16T04:45:04Z Indexed on 2012/11/16 5:00 UTC
Read the original article Hit count: 164

Filed under:
|
|
|

I have a dictionary: Dictionary<int,int>. I want to get new dictionary where keys of original dictionary represent as List<int>. This is what I mean:

var prices = new Dictionary<int,int>();

The prices contain the following data:

1   100
2   200
3   100
4   300

I want to get the IList<Dictionary<int,List<int>>>:

int      List<int>
100      1,3
200      2
300      4

How can I do this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET