C# - Sorting a list when it has more than one value per 'row'?

Provide a ComparisonText); }) You might also want to check for null to be complete, unless you already know there won't be any, as in this case.

Provide a Comparison to instruct the List on how to sort the items. NameList. Sort(delegate(ListItem thisItem, ListItem otherItem) { return thisItem.Text.

CompareTo(otherItem. Text); }); You might also want to check for null to be complete, unless you already know there won't be any, as in this case.

You could also use a lambda expression instead of the anonymous delegate, if you'd prefer and can use . NET 3.5. – bdukes Oct 29 '08 at 19:03 Just curious, how would you do this in VB.NET? – thismat Oct 29 '08 at 19:05 nameList.

Sort(Function(thisItem as ListItem, otherItem as ListItem) return ...) – bdukes Oct 29 '08 at 19:07 Worked, thank you – scrot Oct 29 '08 at 19:09 1 There's no Return in VB lambda syntax, though.It's just Function(x, y) x.Text. CompareTo(y. Text) - and you do not need types for arguments, as they're deduced.

– Pavel Minaev 3.5.8 at 22:21.

EDIT: From what I can tell you will have to specify an IComparer for this to work, not sure if I fully understand what you are trying to do though. EDIT: This is way too complicated for what I "feel" your intent is, you basically want to populate a dropdown list with a sorted list of Author names. You should be able to have a List auhtorNames; authorNames.Sort(); ddl.

DataSource = authorNames; ddl.DataBind().

Names is a hashtable, sorry – scrot Oct 29 '08 at 18:56 I've fixed the code to show everything – scrot Oct 29 '08 at 18:57.

ListItem is not Comparable. You could use a System.Collections.Specialized. OrderedDictionary instead.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions