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

Use natural sorting for map lists (Fixes #892) #907

Merged
merged 1 commit into from Oct 11, 2018

Conversation

@asherkin
Copy link
Member

asherkin commented Oct 10, 2018

This produces consistently better results, especially for games such as L4D(2).

@asherkin asherkin requested review from Drifter321 and Headline Oct 10, 2018
@asherkin asherkin force-pushed the maplist-natural branch from 0d9a6c0 to ef77973 Oct 10, 2018
// if only the right character is a digit, we have a result
if (r_digit) return +1;
// compute the difference of both characters
const int diff=l_char - r_char;

This comment has been minimized.

Copy link
@Drifter321

Drifter321 Oct 11, 2018

Member

Nit : add spaces around "=" to match everything else.

while (*l && alphanum_isdigit(*l))
{
// TODO: this can overflow
l_int=l_int * 10 + *l - '0';

This comment has been minimized.

Copy link
@Drifter321
Copy link
Member

Drifter321 left a comment

Looks good, Only question I have is should we be concerned with the possibility of overflows?

@asherkin asherkin force-pushed the maplist-natural branch from ef77973 to 9f72399 Oct 11, 2018
@asherkin

This comment has been minimized.

Copy link
Member Author

asherkin commented Oct 11, 2018

Only question I have is should we be concerned with the possibility of overflows?

I think we can probably survive slightly incorrect map sorting past 4,294,967,295 alphabetically-identical maps.

@asherkin asherkin merged commit c1d235a into master Oct 11, 2018
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@asherkin asherkin deleted the maplist-natural branch Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.