Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I alphabetically sort a generic List(Of String) in VB.NET?

I've created and populated a generic list of strings like this:

Dim MyList As New List(Of String)
MyList.Add("Beta")
MyList.Add("Echo")
MyList.Add("Charlie")
MyList.Add("Alpha")
MyList.Add("Delta")

Now I want to order it.

like image 372
Zack Peterson Avatar asked Dec 01 '09 23:12

Zack Peterson


People also ask

How do I sort a list in alphabetical order in C#?

You can use LINQ to create a new list which contains the original values but sorted: var sortedList = list. OrderBy(x => x). ToList();


1 Answers

Doesn't this work?

MyList.Sort()
like image 55
Pawel Marciniak Avatar answered Sep 22 '22 05:09

Pawel Marciniak