Index: res/res_musiconhold.c =================================================================== --- res/res_musiconhold.c (revision 199854) +++ res/res_musiconhold.c (working copy) @@ -807,6 +807,16 @@ return 0; } +static int moh_sort_compare(const void *i1, const void *i2) +{ + char *s1, *s2; + + s1 = ((char **) i1)[0]; + s2 = ((char **) i2)[0]; + + return strcasecmp(s1, s2); +} + static int moh_scan_files(struct mohclass *class) { DIR *files_DIR; @@ -879,6 +889,7 @@ ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno)); return -1; } + qsort(&class->filearray[0], class->total_files, sizeof(char *), moh_sort_compare); return class->total_files; }