Use:
using System.Linq.Enumerable; ... List<KeyValuePair<string, string>> myList = aDictionary.ToList(); myList.Sort( delegate(KeyValuePair<string, string> pair1, KeyValuePair<string, string> pair2) { return pair1.Value.CompareTo(pair2.Value); } );
Since you’re targeting .NET 2.0 or above, you can simplify this into lambda syntax — it’s equivalent, but shorter. If you’re targeting .NET 2.0 you can only use this syntax if you’re using the compiler from Visual Studio 2008 (or above).
var myList = aDictionary.ToList(); myList.Sort((pair1,pair2) => pair1.Value.CompareTo(pair2.Value));
Related Posts:
- Best way to randomize an array with .NET
- .Net 4.8 Support for Windows 10 ends in 26 days?
- What is a NullReferenceException, and how do I fix it?
- How do I get a random YouTube video with the YouTube API?
- An existing connection was forcibly closed by the remote host
- What is a NullReferenceException, and how do I fix it?
- I am getting Failed to load resource: net::ERR_BLOCKED_BY_CLIENT with Google chrome
- IOException: The process cannot access the file ‘file path’ because it is being used by another process
- No connection could be made because the target machine actively refused it?
- Could not load file or assembly or one of its dependencies
- What does a lock statement do under the hood?
- Error : Could not load file or assembly or one of it’s dependencies
- Could not load file or assembly or one of its dependencies
- What is C# equivalent of
- Priority queue in .Net
- What is the difference between int, Int16, Int32 and Int64?
- How to open .dll files to see what is written inside?
- Windows .NET API / Windows 7 / Bluetooth communication with Intel Curie Arduino / Genuino 101
- Get current folder path
- foreach vs someList.ForEach(){}
- System.web.mvc missing
- Nullable object must have a value?
- Access to the path is denied
- What does mscorlib stand for?
- What is the best way to iterate over a dictionary?
- WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for jquery
- “Error while trying to run project: Unable to start program”. Can run program only once. Then VS needs restart
- Proper way to initialize a C# dictionary with values
- Add new item in existing array in c#.net
- What is clr.dll on .Net framework and what does it do?
- what is this oleaut32.dll?
- Associating enums with strings in C#
- How do I declare a DefaultValue attribute whose value is an array of strings?
- How to resolve this System.IO.FileNotFoundException
- HttpWebRequest-The remote server returned an error: (400) Bad Request
- Get dictionary value by key
- How to use the “Using” statement in ASP.net razor webpages?
- How can I get the application’s path in a .NET console application?
- Reading settings from app.config or web.config in .NET
- How do I create a Shared Code project (.shproj)
- There is no argument given that corresponds to the required formal parameter – .NET Error
- How do I remedy “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning?
- Collection was modified; enumeration operation may not execute
- Invalid URI: The format of the URI could not be determined
- Could not establish trust relationship for SSL/TLS secure channel — SOAP
- Get single value from dictionary by key
- How to make an HTTP POST web request
- How to add comments into a Xaml file in WPF?
- Why did I get the compile error “Use of unassigned local variable”?
- Reading CSV file and storing values into an array
- Merge two (or more) lists into one, in C# .NET
- How to open a new form from another form
- EntityType has no key defined error
- HTML.ActionLink method
- How do I restart my C# WinForm Application?
- How to split() a delimited string to a List
- Remove element of a regular array
- Best way to reverse a string
- An object reference is required to access a non-static member
- Task vs Thread differences
- Merging two arrays in .NET
- How can I know if a process is running?
- String was not recognized as a valid DateTime ” format dd/MM/yyyy”
- How to update the value stored in Dictionary in C#?
- Substring index and length must refer to a location within the string
- windows could not start service on local computer error 5 access is denied
- Catch multiple exceptions at once?
- How to delete a file after checking whether it exists
- c# Show Windows Form
- How to convert UTF-8 byte[] to string
- .NET String.Format() to add commas in thousands place for a number
- Sort list by field (C#)
- Get dictionary key by value
- The remote server returned an error: (405) Method Not Allowed. WCF REST Service
- Produce a random number in a range using C#
- How do I concatenate two arrays in C#?
- How to play a sound in C#, .NET
- How can I delete a file that is in use by another process?
- Which passwordchar shows a black dot (•) in a winforms textbox?
- How do I fix a .NET windows application crashing at startup with Exception code: 0xE0434352?
- How to resolve file being used by another process?
- How to properly make a http web GET request
- Strip double quotes from a string in .NET
- Convert double to float by cast or Convert.ToSingle()?
- c# .net change label text
- How to avoid a System.Runtime.InteropServices.COMException?
- Using FolderBrowserDialog in WPF application
- Is there an equivalent to the C# “var” keyword in C++/CLI?
- How can I generate random alphanumeric strings?
- Sequence contains more than one element
- How do you do a deep copy of an object in .NET?
- Playing a MP3 file in a WinForm application
- .NET Core vs Mono
- LINQ query on a DataTable
- Encrypt and decrypt a string in C#?
- Unrecognized escape sequence for path string containing backslashes
- C# Dictionary get item by index
- Linq: GroupBy, Sum and Count
- How to enumerate an enum
- How to set session timeout in web.config