WordPress.org

Ready to get started?Download WordPress

Forums

WP-Table Reloaded
[resolved] Does not sort correctly negative values (8 posts)

  1. whoaloic
    Member
    Posted 2 years ago #

    Hello Tobias,
    I notice that the plugin does not sort correctly negative values.
    By example, I have 3 cells with "-1","-11","-3" and when I sort the cells in descending order, it gives me that sorting : "-3", "-11", "-1" and it should be "-1", "-3", "-11".

    Same problem with negative and decimal values.

    Please do you have a solution?

    http://wordpress.org/extend/plugins/wp-table-reloaded/

  2. TobiasBg
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,

    that's probably happening because the sorting algorithm from the DataTables JavaScript library (which does the sorting), detects the cell contents as strings and not as plain numbers. And as strings are sorted differently, you get these results.

    Can you post the URL to the page with your table? I can then try to find out what's causing this in your case.

    Regards,
    Tobias

  3. whoaloic
    Member
    Posted 2 years ago #

    Hi,
    Therefore, is there a way to sort number ?
    here's the URL!

  4. TobiasBg
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,

    thanks for the link.

    The reason in your case is that you are using commas (,) in your numbers. I know that this is the common character to use in France (and here in Germany, too), but unfortunately, the DataTables library is developed in Great Britain (see http://www.datatables.net), where a period (.) is used as a decimal delimiter.

    Therefore, I suggest that you replace all , with . in your cells. Another idea could be to install this plugin extension: http://tobias.baethge.com/download/plugins/additional/wp-table-reloaded-commavalues.zip

    Regards,
    Tobias

  5. whoaloic
    Member
    Posted 2 years ago #

    Thank you for you answer,
    OK for using a period instead of a comma.

    Regarding the plugin extension (I install it as a usual plugin), it does not change anything if I keep commas.

    Regards

  6. TobiasBg
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,

    if using a period works for you, that's great!

    The plugin extension is rather old already, so it might not work anymore. I'll have to take a deeper look once I find the time. And it might be that it actually had a different purpose (namely allowing commas a thousand separators), I don't really remember at the moment...

    Best wishes,
    Tobias

  7. whoaloic
    Member
    Posted 2 years ago #

    Thank you for taking time to answer Tobias,
    regards.

  8. TobiasBg
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,

    no problem, you are very welcome!

    Best wishes,
    Tobias

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic