Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't sort column of float values? #41

Open
connerxyz opened this issue Jun 17, 2018 · 2 comments
Open

Can't sort column of float values? #41

connerxyz opened this issue Jun 17, 2018 · 2 comments

Comments

@connerxyz
Copy link

Here's my code to sort a column of float values. It continues to be sorted as if they're strings though. The table simply has <thead>...<th>amount</th></thead>, no class or id or anything.

Thanks in advance for any insight.

$(document).ready(function() {
    $('table').tablesort()
    $('thead th.amount').data(
        'sortBy', 
        function(th, td, tablesort) {
            return parseFloat(td.text());
        }
    );
})
@Webby
Copy link

Webby commented Sep 16, 2018

Hello,

You need to put <th class="amount">Amount</th> in your table header

Best,
Anthony

@connerxyz
Copy link
Author

Of course. Thank you @Webby!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants