stationer / SortTable

A pure JavaScript (no dependencies) solution to make HTML Tables sortable
MIT License
37 stars 12 forks source link

Number sort does not work with floats #10

Closed davidRsully closed 1 year ago

davidRsully commented 1 year ago

When the number is 24.8 then the next number shows up 3.3. 3.3 is way less than 24.8 but sort is acting like this is alphabetic not a float.

Is there a way to use parseFloat for floating point numbers?

tyleruebele commented 1 year ago

Did you add class="js-sort-number" to the table header? That clues it to use sortTable.number() which uses the built in Number to parse/convert the content to a number. See https://github.com/stationer/SortTable/blob/master/demo.html for examples.

davidRsully commented 1 year ago

First off, thank you for your quick reply.

I’m sure I left that out of the header, and will put that in for my next test.

Your sortable works the best of any I have found. And I thought it strange that you would not have taken that into account.

Sorry for my not being thorough enough with the details.

David

On Mon, Feb 13, 2023 at 11:58 AM Tyler Uebele @.***> wrote:

Did you add class="js-sort-number" to the table header? That clues it to use sortTable.number() which uses the built in Number to parse/convert the content to a number. See https://github.com/stationer/SortTable/blob/master/demo.html for examples.

— Reply to this email directly, view it on GitHub https://github.com/stationer/SortTable/issues/10#issuecomment-1428486781, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC472TF6PQZZEOAWAK23DOLWXJ75JANCNFSM6AAAAAAU2TCM7Y . You are receiving this because you authored the thread.Message ID: @.***>

-- David Sullivan

tyleruebele commented 1 year ago

I'm glad you're getting good use from it. Let me know if that solved your issue.

davidRsully commented 1 year ago

It sure does, thanks again for your help.

On Tue, Feb 14, 2023 at 7:47 AM Tyler Uebele @.***> wrote:

I'm glad you're getting good use from it. Let me know if that solved your issue.

— Reply to this email directly, view it on GitHub https://github.com/stationer/SortTable/issues/10#issuecomment-1429863973, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC472TDCMS7V6XJQNTLYOZDWXOLI5ANCNFSM6AAAAAAU2TCM7Y . You are receiving this because you authored the thread.Message ID: @.***>

-- David Sullivan