forked from KiaraGrouwstra/pquery
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathText.MixedSort.pq
More file actions
15 lines (13 loc) · 841 Bytes
/
Text.MixedSort.pq
File metadata and controls
15 lines (13 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// About// Sorts mixed list of text and numbers in a numerical order for numbers and alphanumeric for text
// Arguments// "txt"= Text value to sort
// Source// Author: Bill Szysz in https://social.technet.microsoft.com/Forums/en-US/aed476c6-0daa-4aa2-b763-993195d4d0eb/how-to-sort-in-cell-values-with-comma-seperated-using-power-query?forum=powerquery
// Imp// Suggested improvement: Integrate option to choose order direction (ascending, descending) by function parameters
(txt as text) as text =>
let
SplitTrim = List.Transform(Text.Split(txt, ","), each Text.Trim(_)),
Transform = List.Transform(SplitTrim, each try Number.From(_) otherwise _),
LstSort = List.Sort(Transform, 0),
Transform2 = List.Transform(LstSort, each Text.From(_)),
CombineText = Text.Combine(Transform2, ", ")
in
CombineText