Sorting Alpha-Numeric String Fields Numerically?

Copper Contributor

Hi,

In Sharepoint my file names are string types that contain both letters and numbers. How do I get the files to sort numerically (i.e. 1, 5, 13, 20) as opposed to sorting it like text (i.e. 1, 13, 20, 5)?

 

There are many many files. I'm aware that keeping all numbers the same length avoids this issue (i.e. 001, 005, 013, 020) but would like to avoid going back and changing these one by one.

 

Is there some sort of JSON code you can write in the custom formatting section? Any help is appreciated. I am completely unfamiliar with JSON.

4 Replies
I have the same issue
You could create a new number column "SortOrder" and a Flow that sets the value of the "SortOrder" column to the number part of your filename...
Then sort by that column

@SvenSieverding Thank you. this solution was brought forth several times but in document control most of the time the unique document code will be put in file name as well and this is how we sometimes deliver the set of document packages. I'm looking for solution that require less work on my side since the correct sorting is already there on the file name.

@LTJ88 Since it was released over 20 years ago, sharePoint has always sorted sorted left to right for single line of text columns. Other than the workarounds previously suggested there is no way to get it to sort in the way you want. So you will always get a result like this:

ABC2
ABC20

ABC21
ABC22
ABC3

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)