currency parser: thousands separator support#34
Open
mbezhanov wants to merge 2 commits into
Open
Conversation
Author
|
I have also added thousands separator support for the "digits" parser with the latest commit. And here is an online demo: http://mbezhanov.github.io/tablesorter/example-thousands-separator.html After reading #26 though, I'm not sure how much of a good idea that is... |
Collaborator
|
In my fork of tablesorter, I tackled this problem by adding a When that option is Edit: Hmm, I guess it doesn't cover French Swiss formatting: but in the currency parser, I do replace all non-digit characters as well: $.tablesorter.formatFloat((s || '').replace(/[^\w,. \-()]/g, ""), table); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When working with large figures in accounting applications, it's often preferred to format your numbers with grouped thousands through thousands separators. In example, presenting a large figure like $1386915 as $1,386,915 instead, makes it much more readable to the end-user.
Most server-side scripting languages and spreadsheet applications provide all the necessary functionality for the purpose, in example:
http://php.net/manual/en/function.number-format.php
http://office.microsoft.com/en-001/excel-help/format-numbers-as-currency-HA102749029.aspx
...so many people rely on these functions in their everyday work to format and present their figures properly.
Unfortunately, Tablesorter doesn't provide native support to figures utilizing the aforementioned format, so if a user decides to present financial information formatted with thousands separators, Tablesorter identifies the data type as "currency", but is unable to sort it properly.
Therefore, I went ahead and added some minor modifications, so the currency parser can successfully sort figures, which make a use of thousands separators.
I have already used this functionality in a couple of projects and it works great. I hope it's useful to the community too.
All best,
Marin