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

Strings after the number are ignored. #7

Open
ddYoder opened this issue Aug 15, 2017 · 0 comments
Open

Strings after the number are ignored. #7

ddYoder opened this issue Aug 15, 2017 · 0 comments

Comments

@ddYoder
Copy link

ddYoder commented Aug 15, 2017

In both version 1.1.1 and 1.2.0, the natural_sort algorithm is unable to properly (or consistently) sort an array such as the following:
%w(BALNOR2 CKNOR2 NOR2I NOR2 NOR3I NOR3 NOR4)

In the code:
sa, sb = a.to_s, b.to_s
if (sa.downcase <=> sb.downcase) == 0 then sa <=> sb
else
na, nb = check_regexp(sa, sb)
na <=> nb
end

When trying to compare NOR2 & NOR2I (or NOR3 & NOR3I), the check_regexp method removes the trailing 'I' character so that na, nb have the same value and the na <=> nb expression is 0 which is incorrect for sa <=> sb.

Thanks,
Doug

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

1 participant