Index: main/pbx.c =================================================================== --- main/pbx.c (revision 218577) +++ main/pbx.c (working copy) @@ -2210,7 +2210,8 @@ * If a is not a pattern, it either comes first or * we use strcmp to compare the strings. */ - int ret = 0; + int ret = 0, res = 0; + const char *orig_a = a, *orig_b = b; if (a[0] != '_') return (b[0] == '_') ? -1 : strcmp(a, b); @@ -2223,11 +2224,13 @@ #endif /* ok we need full pattern sorting routine */ while (!ret && a && b) - ret = ext_cmp1(&a) - ext_cmp1(&b); - if (ret == 0) - return 0; - else + ret = (res = ext_cmp1(&a)) - ext_cmp1(&b); + if (ret == 0) { + /* More specific match required? */ + return (res & 0xff) ? strcmp(orig_a, orig_b) : 0; + } else { return (ret > 0) ? 1 : -1; + } } int ast_extension_cmp(const char *a, const char *b)