SOLVED

Sorting Numbers Withing a Text String

Copper Contributor

Usually I can think of at least a thought process of where to go, but stumped on this one...

I have a text field with a six digit text string, as an example '201210', i would like to sort those six digits into a new text string, so in the example above i would end up with a new text string '221100'.

 

Anyone have an idea where to start with th

3 Replies
best response confirmed by DarrylJP (Copper Contributor)
Solution

@DarrylJP Below formula may help-

=LET(x,SUBSTITUTE(A1,"'",""),y,MID(x,SEQUENCE(LEN(x)),1),"'"&CONCAT(SORT(y,,-1))&"'")

 

Harun24HR_0-1668392380259.png

 

If you have the input text in A1, then:

 

=LET(x, SUBSTITUTE(A1,"'",""), 
 "'"&TEXTJOIN("",,SORT(MID(x, SEQUENCE(LEN(x)),1),,-1))&"'")

 

it returns: '221100'

 

Thanks Harun24HR! My brain would have never gone there, greatly appreciated!
1 best response

Accepted Solutions
best response confirmed by DarrylJP (Copper Contributor)
Solution

@DarrylJP Below formula may help-

=LET(x,SUBSTITUTE(A1,"'",""),y,MID(x,SEQUENCE(LEN(x)),1),"'"&CONCAT(SORT(y,,-1))&"'")

 

Harun24HR_0-1668392380259.png

 

View solution in original post