Forum Discussion

AWitt77's avatar
AWitt77
Copper Contributor
Nov 30, 2020

Sorting a mixed text/number Column by number on a Mac

I'm on a Mac and trying to sort a column by numbers but it's not sorting how you would actually count.  For instance, instead of sorting 1 through 20 as you'd normally count, it is sorting 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 3, 4, 5, 6, 7, 8, 9.

 

The column is mixed text/number and I've tried selecting the column as text, number, general, etc. and it doesn't change the sorting to a natural count style.

 

Any help is appreciated, thank you!

  • Riny_van_Eekelen's avatar
    Riny_van_Eekelen
    Platinum Contributor

    AWitt77 You need to transform all entries in the column to real numbers. Simply setting the format is not sufficient. Select the column with the "numbers". On the Data ribbon select "Text to Columns".

    Click "Next". until you reach step 3 of 3, Make sure  "General" is selected. Press Finish. Now you will have real numbers that can be sorted as you expect then to be.

      • paulcechovicgmailcom's avatar
        paulcechovicgmailcom
        Copper Contributor

        AWitt77 

        I have the following data in a column. 1, 1A, 2, 1B. 401B, 400. I would like them sorted as 1, 1A, 1B, 2, 400, 401B. How do I create this 'natural sort' ?  Thanks

    • paulcechovicgmailcom's avatar
      paulcechovicgmailcom
      Copper Contributor

      Riny_van_Eekelen   Hi Riny:   I have tried your solution on some test data and IT WORKS.  I am very appreciative of your help.  thank you very much.   Paul

      • paulcechovicgmailcom's avatar
        paulcechovicgmailcom
        Copper Contributor
        What worked for me. and my data.
        Add a space between number and alpha using Flash Fill. 1045A becomes 1045 A
        Highlight the column and select data, then "Text to columns. This creates a second column with the alpha data. Now sort: first on the numeric column and then on the alpha column. Thanks to all for helping me get through this puzzeler.

Resources