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

Leading Zeros #6

Closed
Mottie opened this issue Aug 6, 2012 · 2 comments
Closed

Leading Zeros #6

Mottie opened this issue Aug 6, 2012 · 2 comments
Assignees

Comments

@Mottie
Copy link
Contributor

Mottie commented Aug 6, 2012

Hi, I've been using your Natural Sort to replace the sorting algorithm in my fork of jQuery tablesorter

But if you check out the first column of this demo you'll see that A02 and A012 don't sort correctly

I've found that if I change line 29 & 30 to the following, it works properly:

oFxNcL = isNaN(xN[cLoc]) ? xN[cLoc] || 0 : parseFloat(xN[cLoc]) || 0;
oFyNcL = isNaN(yN[cLoc]) ? yN[cLoc] || 0 : parseFloat(yN[cLoc]) || 0;

Edit: here is a simplified version : http://jsfiddle.net/Mottie/LannP/

@overset
Copy link
Owner

overset commented Aug 7, 2012

Thanks for catching this! I can definitely see use cases with 0 left padded numbers that start with another character. I just did a quick test with your changes against the existing the unit-tests.html and it's breaking a couple of other sorts that should work. Let me try and go off your A02 and A012 example, build a few test cases and see if I can get something to work for all the test cases. On that note - have any other ideas on what I can ensure this will sort properly so I can build some more test cases..?

http://overset.github.com/javascript-natural-sort/unit-tests.html

@ghost ghost assigned overset Aug 7, 2012
@Mottie
Copy link
Contributor Author

Mottie commented Aug 7, 2012

DOH, I forgot to check the unit tests! I haven't run into any other cases that don't work correctly, but I'll be sure to post an issue if I do run into any.

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