Implemented alphanum quicksort

This commit is contained in:
Dylan G
2017-10-15 13:18:53 +01:00
parent 24810a48ad
commit b5c78cf68b
2 changed files with 11 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ int theme_count;
void load_theme_preview(Theme_s *theme);
Result get_themes(Theme_s **themes_list, int *theme_count);
int themecmp(const void* a, const void* b);
void del_theme(u16 *path);
Result single_install(Theme_s theme);
Result shuffle_install(Theme_s *themes_list, int theme_count);

View File

@@ -201,10 +201,20 @@ Result get_themes(Theme_s **themes_list, int *theme_count)
}
FSDIR_Close(dir_handle);
qsort(*themes_list, (long)*theme_count, sizeof(Theme_s), themecmp); //alphabet sort
return res;
}
int themecmp(const void* a, const void* b) //essentially a memcmp alias, so that it can be used properly with qsort
{
Theme_s *theme_a = (Theme_s *)a;
Theme_s *theme_b = (Theme_s *)b;
return memcmp(theme_a, theme_b, 0x40*sizeof(u16));
}
void del_theme(u16 *path)
{
Handle dir_handle;