-3

I need to Sort a List in c# that has data like

{"301","301b","301a","300",302}

Expected output

{"300","301","301a","301b",302}
Dmitry Bychenko
  • 180,369
  • 20
  • 160
  • 215
  • 1
    hi and welcome to StackOverflow. Actually we expect at least a little effort from you to solve your problem. This is not a code writing service where you dump your requirements and others do your work. For the future, please provide some code that shows how you tried to tackle the problem, also describe what problem you have encountered with your code, and then we can help you to solve this problem. – Mong Zhu Sep 14 '22 at 12:11
  • Does this answer your question? [Natural Sort Order in C#](https://stackoverflow.com/questions/248603/natural-sort-order-in-c-sharp) – Charlieface Sep 14 '22 at 14:48

1 Answers1

2

Below one is your expected answer to make list in order.

List<string> abc=new List<string>() {"301","301b","301a","300","302"};
        
Console.WriteLine("Hello World {0}",string.Join("|",abc.OrderBy(x=>x).ToList()));

working example

Kiran Joshi
  • 1,758
  • 2
  • 11
  • 34