• Resolved jsnowbusiness

    (@jsnowbusiness)


    I have a column of numbers that wouldn’t sort properly, I found the command “columnDefs”: [ { “type”: “numeric”, “targets”: 4 } ] here in the support threads which doesn’t seem to help.

    My column of numbers does has some asterisks at the end of some of the numbers, however those numbers still seem to be sorting fine. The only value not sorting properly is the only number over 100.

    Table Pic

    So my question is.. are the asterisks screwing with sorting? Is my custom command wrong? Or is the problem that I need ugly leading-zeroes?

    Thanks for the help!

    • This topic was modified 9 years, 5 months ago by jsnowbusiness.
    • This topic was modified 9 years, 5 months ago by jsnowbusiness. Reason: clarification
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Yes, this is caused by the *. Those are turning the cell data type into “string”, and strings are sorted differently.
    If you want to keep those, you could take a look at an approach that uses a hidden column with the plain numeric data and uses that for the sorting. For details, please see the (very similar) example at https://ww.wp.xz.cn/support/topic/consolidating-columns-without-changing-sorting-options/

    Regards,
    Tobias

    Thread Starter jsnowbusiness

    (@jsnowbusiness)

    Thank you!

    So I’ve done what was suggested in that topic (created another column of just numerals for sorting) and changed my custom command to this “columnDefs”: [ { “orderData”: [4 ], “targets”: [ 8] }, { “visible”: false, “targets”: [ 8 ] } ] since my visual column is E/#5 and the sort data column is I/#9.

    This is the result:

    table sort pic2

    Should I be combining my old custom command with this new addition?

    Thanks again for all the help.

    -John Snow

    • This reply was modified 9 years, 5 months ago by jsnowbusiness.
    • This reply was modified 9 years, 5 months ago by jsnowbusiness. Reason: typo in command
    Thread Starter jsnowbusiness

    (@jsnowbusiness)

    Nevermind..

    I see it should be “columnDefs”: [ { “orderData”: [ 8 ], “targets”: [ 4 ] }, { “visible”: false, “targets”: [ 8 ] } ]

    All is working well now!

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! 🙂 Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Numeric Column Sorting Clarification’ is closed to new replies.