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

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

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

Choose a reason for hiding this comment

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

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

@asherkin
Copy link
Member Author

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
@asherkin asherkin deleted the maplist-natural branch October 11, 2018 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request user requested feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants