Skip to content

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

Merged
asherkin merged 1 commit intomasterfrom
maplist-natural
Oct 11, 2018
Merged

Use natural sorting for map lists (Fixes #892)#907
asherkin merged 1 commit intomasterfrom
maplist-natural

Conversation

@asherkin
Copy link
Member

@asherkin asherkin commented Oct 10, 2018

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

@asherkin asherkin added the Feature Request user requested feature label 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;
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