rows.map ( ( record ) => {
try {
(async () => {
let col = await client.query(`SELECT * FROM customers`);
})();
} catch (err) {
console.log(err);
}
});
包含3种类型的内容:
ColumnA
包含日期格式" YYYYMMDD "。
我需要根据3种内容类型对数据进行分组,然后按日期升序排序。
示例:
ColumnA | ColumnB A123457 | 20171114 B246734 | 20171009 1234544 | 20170808 6789033 | 20171220 ABBCDEE | 20180102 A112233 | 20160202 1212122 | 20171115 NNNNNNN | 20171011
根据ColumnB
值进行分组并根据ColumnA
值进行排序:
ColumnA | ColumnB 1234544 | 20170808 1212122 | 20171115 6789033 | 20171220 A112233 | 20160202 B246734 | 20171009 A123457 | 20171114 NNNNNNN | 20171011 ABBCDEE | 20180102
我们将成为LINQ解决方案吗?
答案 0 :(得分:1)
下面不是确切的代码,通过以下方式可以达到预期的效果。
//sort the date and put into same list
CultureInfo provider = CultureInfo.InvariantCulture;
myList.ForEach(i => { i.ColumnB = DateTime.ParseExact(i.ColumnB, "YYYYMMDD", provider);});
//check for regex match and add to list
mynumericlist = myList.Where(x => Regex.IsMatch(x.columnA, @"^\d$")).ToList().OrderBy(x=>x.ColumnB);
myalphalist = myList.Where(x => Regex.IsMatch(x.columnA, @"^[a-zA-Z]*$")).ToList().OrderBy(x => x.ColumnB);
myalpnumlist = myList.Where(x => Regex.IsMatch(x.columnA, @"^[a-zA-Z0-9]*$")).ToList().OrderBy(x => x.ColumnB);
//then combine all