-1

I recently stumbled upon IComparer and I think it can help me sort my alphanumeric string list. // "STATE-ShipSpeed-0001"

List<string> myList = new List<string>{
"TX-S3-1005",
"CA-S3-1205",
"NV-S2-1001",
"LA-S5-1015",
"VA-S1-1305",
};

From what I've read IComparer should be able to sort the list above in order, but I have absolutely no idea where to being. Could someone assist or help me?

snapplex
  • 851
  • 3
  • 13
  • 27

1 Answers1

0

See code below:

List<string> myList = new List<string>{
"TX-S3-1005",
"CA-S3-1205",
"NV-S2-1001",
"LA-S5-1015",
"VA-S1-1305",
};

sortedList = myList.OrderBy(s => s).ToList();
Riad Baghbanli
  • 3,105
  • 1
  • 12
  • 20