次の文字列のリストがあります
var strTest = new List<string> { "B2", "B1", "B10", "B3" };
「B1、B2、B3、B10」のように並べ替えたいと思います。
LINQ OrderBy を使用すると、「B1、B10、B2、B3」のように並べ替えられます
助けてください。これが私のコードです。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SortingDemo
{
class Program
{
static void Main(string[] args)
{
var strTest = new List<string> { "B2", "B1", "B10", "B3" };
var sort = strTest.OrderBy(x => x);
var sortedStr = string.Join(",", sort);
Console.WriteLine(sortedStr);
Console.ReadLine();
}