-
Notifications
You must be signed in to change notification settings - Fork 754
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
Leading zeros are ignored when sorting text columns #409
Comments
The default text sorter is the natural sort, which behaves like a numerical sort, but is slightly slower than a straight numerical sort. Instead set the $(function() {
$("table").tablesorter({
textSorter: {
0: $.tablesorter.sortText
}
});
}); |
funny i was just creating an example to show this: http://jsfiddle.net/4mVfu/1131/ |
Hehe, thanks :P The // basic alphabetical sort
ts.sortText = function(a, b) {
return a > b ? 1 : (a < b ? -1 : 0);
}; |
Thanks for explaining this. I spent a while reading the docs but couldn't find what I was looking for and even now I know what to look for I can't find documentation on sortNatural and sortText. Thanks again |
I guess it's not that obvious... look at the last code block under the |
A text column is being sorted as follows:
1
2
3
00004
4
5
6
7
8
9
See http://jsfiddle.net/rbirkby/HQ7mg/4/
I would expect the 00004 value to be ordered first.
This is not what I would expect, nor is it how JavaScript will sort.
The text was updated successfully, but these errors were encountered: