score:8
Accepted answer
Try the following
dictionary
.SelectMany(pair => Enumerable.Repeat((double)pair.Key, pair.Value))
.OrderByDescending(x => x)
.ToList();
score:1
foreach (var pair in dict)
for (int i=0;i<pair.Value;i++)
list.Add((double)pair.Key);
score:5
dictionary
.SelectMany(kvp => Enumerable.Repeat(Decimal.ToDouble(kvp.Key), kvp.Value))
.ToList()
score:0
public static IEnumerable<T> Blowout<T>(T value, int length)
{
for (int i = 0; i < length; i++) yield return value;
}
dictionary
.SelectMany(pair => Blowout((double)pair.Key, pair.Value));
Source: stackoverflow.com
Related Articles
- Blow dictionary out to a list
- List or Array of String Contain specific word in Html Source Code
- c# Linq or code to extract groups from a single list of source data
- Convert list to dictionary using linq and not worrying about duplicates
- LINQ - Convert List to Dictionary with Value as List
- Create a dictionary on a list with grouping
- Convert dictionary values to list using linq
- LINQ: Getting Keys for a given list of Values from Dictionary and vice versa
- Linq Query Dictionary where value in List
- C# LINQ - convert nested dictionary to a list
- Generating the Shortest Regex Dynamically from a source List of Strings
- Convert a list to a dictionary and sum up values using linq
- List to Dictionary with incremental keys in one line LINQ statement
- Search dictionary values and return List of keys meeting conditions
- How do I combine the keys and values of a Dictionary into one List using LINQ?
- Create and initialize dictionary from list
- LINQ querying a Dictionary against a List
- Finding a value from within a List of Dictionary objects
- Coercing a LINQ result list of KeyValuePair into a Dictionary - Missing the Concept
- LINQ Source Code Available
- Use linq expression to filter a dictionary with a list of keys
- List of Dictionary to List<Type> using Linq
- Linq to Dictionary with key and a list
- Merging Dictionary containing a List in C#
- Select All object values to list from dictionary
- .NET 4 Code Contracts: "requires unproven: source != null"
- Joining Dictionary key that matches class List's list item into a new list - C#
- How to convert Dictionary to List with mixing of values and keys?
- C# List to Dictionary without Foreach [ERROR]
- Transfor List to Nested Dictionary using linq C#
- How can I create a method that will print LINQ query results?
- Linq left join with condition with nullable string
- RavenDB: Search with whitespace, behaving like String.Contains
- c# How to use linq to get xml string by filtering some data?
- Splitting the string and sorting - Linq
- LINQ Pivot to Excel File
- How can I determine if an entity collection contains one of several possible values?
- Getting columns from join columns with EF query
- sql query that needs to be grouped and sent to json format mvc
- Set LINQ DSN for DataContext
- Flagged Enum Consolidation (Inverse of Combination) Using LINQ
- SQL query with group by and where filtering a received parameter
- What is the best way to query a database for records within n miles of a zip code?
- Linq expression to validate if list is ordered ascending or descending
- Cast a LINQ-to-Entites model with a join
- Dynamic Join of multiple entities based on some filter in Entity Framework
- Linq Filter Collection Inside Collection
- about return type in linq
- Finding List A in List B?
- Newtonsoft JArray LINQ - Group By array with identical values