- let
- 源 = Excel.CurrentWorkbook(){[Name="表5"]}[Content],
- t = Table.TransformColumns( 源,{},(s)=>
- [ ax=List.Generate(()=>[a=0,b=s],(x)=>x[a]>=0,(y)=>
- [ ay=Text.BetweenDelimiters(s,"(",")",y[a]),
- a=if ay="" then -1 else y[a]+1,
- by=if ay="" then "" else List.Sort(Text.Split(ay,","),{each Number.From(Text.Split(_,":"){1}),0} ),
- b=if ay="" then "" else Text.Replace(y[b],ay,Text.Combine(by,",")) ]),
- bx=List.Last(ax)[b] ][bx])
- in
- t
复制代码
可以对多列、字符串n段循环排序。因字符串分割后有索引号,所以稍微修改代码,可对字符串分数自定义排序,如前2个分割段升序,后面是降序,也可间隔升降序等。 |