Getting a SharePoint Library to sort in numerical order

Anonymous
2020-07-15T00:06:48+00:00

I'm on a client site and have been given a complex doc library to manage. Everything is nested in multiple folders so I'm wanting to demonstrate the virtues of using tags, sorting and grouping which makes library content easy to find. However I'm finding that if I have a list of subjects starting with a number (this is something I inherited) that if I sort the list in subject order, it doesn't display in numerical order, which is kind of clunky - note that Subject 11 appears before 3:

So, I created another field - a sorting field named Subject# which is a number field  - with just the subject number in it, and set the list to sort by this field, but group by Subject.  But after doing that, it still sorts in non-numerical order as above (note that not all the subjects are populated yet).

Any tips? It seems such a simple and obvious thing to be able to do, but looking around at posts on this it seems a long-standing problem with SharePoint sorting.

Microsoft 365 and Office | SharePoint | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Anonymous
    2020-07-15T05:23:48+00:00

    Dear Jonathan,

    Thanks for posting the thread on our forum.

    Based on your description, I guess that you create a site library like the following. The Subject column is a choice type column with eth choice selections

    0: test1, 1: test2, 2: test3, 3: test4, 4: test5, 5: test6, 6: test7, 7: test7, 8: test8, 9: test9, 10: test10, 11: test11, 12: test12.

    If yes, I suggest you create a calculated column naming Subject Sort to achieve your requirement. You can type the formula like the following and set the value as number.

    =IF(Subject="0: test1",1,IF(Subject="1: test2",2,IF(Subject="2: test3",3,IF(Subject="3: test4",4,IF(Subject="4: test5",5,IF(Subject="5: test6",6,IF(Subject="6: test7",7,IF(Subject="7: test7",8,IF(Subject="8: test8",9,IF(Subject="9: test9",10,IF(Subject="10: test10",11,IF(Subject="11: test11",12,IF(Subject="12: test12",13)))))))))))))

    Then group the Subject Sort column and the Subject Column. The view may be showed with some little problem when using the modern SharePoint UI. I suggest you use the classic SharePoint UI. If you want to use some modern web parts on the modern site page, I suggest you use the Embed web part with the code as follows to embed the classic page on a modern page as well.

    The modern SharePoint UI.

    The classic SharePoint UI.

    The embed experience on the modern site page. You can also enable custom script in SharePoint Online Management Shell with the command

    Set-SPOsite <SiteURL> -DenyAddAndCustomizePages 0 and insert the code as follows to hide the left navigation bar to make the classic page look better.

    <style type="text/css">

        #s4-ribbonrow, .ms-cui-topBar2, .s4-notdlg, .s4-pr s4-ribbonrowhidetitle, .s4-notdlg noindex, #ms-cui-ribbonTopBars, #s4-titlerow, #s4-pr s4-notdlg s4-titlerowhidetitle, #s4-leftpanel-content {display:normal !important;}

        .s4-ca {margin-left:0px !important; margin-right:0px !important;}

        .ms-core-navigation { display: none; }

        #contentBox { margin-left: 0; }

    </style>

    The embed code is like the following.

    <iframe width="100%" height="500" src="xxx"></iframe>

    Best Regards,

    Cliff

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2020-07-15T05:36:49+00:00

    Thanks, Cliff, but consider how simple the requirement is  - 'sort list in natural order' - the proposed fix is too complicated. I will have to work out another way to go about it.

    43 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2020-07-16T10:22:53+00:00

    Dear Jonathan,

    As the column Subject's value contains text and number in your environment, the Group By feature may not sort it as number order now. So you may need to use the out-of-box-feature Calculated Column to automatically show the number of the Subject column and then use the Group By feature to show the number order based on the calculated column.

    I know it is more convenient using the Group By feature on the Subject column directly in SharePoint Online. I kindly suggest you submit your feedback on  the SharePoint UserVoice platform to let our product developers know your suggestions and requirements for product improvements. I hope that it can be achieved soon.

    Thanks for your understanding and have a nice day!

    Cliff

    2 people found this answer helpful.
    0 comments No comments