Skip to content

Commit

Permalink
Sort Amiibos by name
Browse files Browse the repository at this point in the history
Added the code I wrote for N-Xplorer to sort the Amiibos by their name in the list
  • Loading branch information
CompSciOrBust committed Jan 30, 2020
1 parent f2b91d6 commit 95be031
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ INCLUDES := include
#ROMFS := romfs
APP_TITLE := Amiigo
APP_AUTHOR := CompSciOrBust
APP_VERSION := 1.5.3
APP_VERSION := 1.6.0

#---------------------------------------------------------------------------------
# options for code generation
Expand Down
15 changes: 14 additions & 1 deletion source/AmiigoUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,20 @@ void AmiigoUI::ScanForAmiibos()
Files.push_back(*ent);
}
closedir(dir);

//Sort the dirs by name
std::sort(Files.begin(), Files.end(), [](dirent A, dirent B) -> bool{
int MaxLength = 0;
if(sizeof(A.d_name) > sizeof(B.d_name)) MaxLength = sizeof(A.d_name);
else MaxLength = sizeof(B.d_name);
int Itterate = 0;
while(Itterate < MaxLength)
{
if(tolower(A.d_name[Itterate]) != tolower(B.d_name[Itterate])) break;
else Itterate++;
}
return tolower(A.d_name[Itterate]) < tolower(B.d_name[Itterate]);
});
//Add the dirs to the list
AmiiboList->ListingTextVec.clear();
for(int i = 0; i < Files.size(); i++)
{
Expand Down

0 comments on commit 95be031

Please sign in to comment.