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
Merged

Conversation

@asherkin
Copy link
Member

@asherkin asherkin commented Oct 10, 2018

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

// 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;
Copy link
Member

@Drifter321 Drifter321 Oct 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

@Drifter321 Drifter321 Oct 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Member

@Drifter321 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
Copy link
Member Author

@asherkin 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
@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
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants