Solved

Simple way to sort a collection class

Posted on 2011-09-21
2
233 Views
Last Modified: 2012-05-12
I have a collection of countries, called CountryCollection, defined thus:

public class CountryCollection : KeyedCollection<string, Country>

A country has a CountryName and CountryCode, among other things.

What is the best/easiest way to sort the collection by CountryName in C# ?
0
Comment
Question by:purplesoup
2 Comments
 
LVL 9

Accepted Solution

by:
xav056 earned 250 total points
ID: 36574083
Use a cortedDictionary collection
http://msdn.microsoft.com/en-us/library/f7fta44c.aspx
0
 
LVL 5

Assisted Solution

by:Eduardo Goicovich
Eduardo Goicovich earned 250 total points
ID: 36574108
basically involves sorting the underlying List of the collection

example here

http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/56adc0f9-aa1b-4acf-8546-082bb01058f2/
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question