用正则表达式获取json字段排序
var Reg01 = new Regex($"\"fd9e\"\\s*?:\\s*?(\".*?)\"");
var Reg02 = new Regex($"\"fe1e\"\\s*?:\\s*?(\".*?)\"");
dtoList = dtoList.Select(a => new {
dto=a,
H = getMatchReg01(Reg02, a.CustomField), // 厚
W = getMatchReg01(Reg01, a.CustomField), // 宽
}) .OrderBy(o => o.H).ThenBy(x=>x.W).Select(a=>a.dto).ToList();
/// <summary>
/// 验证
/// </summary>
/// <param name="reg01"></param>
/// <param name="customField"></param>
/// <returns></returns>
private decimal getMatchReg01(Regex reg01, string customField)
{
decimal w = 0;
string width = String.Empty;
var widthM = reg01.Match(customField);
if (widthM.Success)
w = string.IsNullOrEmpty(widthM.Groups[1].Value)?0:Convert.ToDecimal(widthM.Groups[1].Value);
return w;
}

浙公网安备 33010602011771号