How to sort a string array which includes a date in c#?

前端 未结 2 553
眼角桃花
眼角桃花 2021-01-27 17:16

I\'m not sure if this has been asked before, but I have few string array which I need to sort. The idea is to merge different string arrays and sort them by the date field which

2条回答
  •  后悔当初
    2021-01-27 18:14

    Try something like:

    var sorted = input.OrderBy(line => DateTime.Parse(line.Split('|').Last()))
                      .ToArray();
    

提交回复
热议问题