Skip to content

Commit

Permalink
fix config list alphanumircal sorting function
Browse files Browse the repository at this point in the history
  • Loading branch information
sedenion committed Nov 19, 2017
1 parent fa967b5 commit 6419668
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/gme_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,32 @@ int g_GameCur_Id = -1;

bool GME_GameSortCfgComp(const GME_GameCfg_Struct& a_cfg, const GME_GameCfg_Struct& b_cfg)
{
// convert to ASCII
std::string a_title = GME_StrToMbs(a_cfg.title);
std::string b_title = GME_StrToMbs(b_cfg.title);

// Convert to upper case to compare ASCII values
GME_StrToUpper(a_title);
GME_StrToUpper(b_title);

// test against the shorter string
size_t l = a_title.size() > b_title.size() ? b_title.size() : a_title.size();

// test for ASCII value greater than the other
for(unsigned i = 0; i < l; i++) {
if(a_title[i] < b_title[i]) {
return true;
} else {
return false;
if(a_title[i] != b_title[i]) {
if(a_title[i] < b_title[i]) {
return true;
} else {
return false;
}
}
}

// tested strings portions are equals, we sort by string size
if(a_title.size() < b_title.size())
return true;

return false;
}

Expand Down

1 comment on commit 6419668

@Chikaze
Copy link

@Chikaze Chikaze commented on 6419668 Nov 5, 2019

Choose a reason for hiding this comment

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

request mklink(Hard Link)

Please sign in to comment.