diff -up man-db-2.5.9/src/man.c.pom man-db-2.5.9/src/man.c --- man-db-2.5.9/src/man.c.pom 2010-11-17 12:31:24.000000000 +0100 +++ man-db-2.5.9/src/man.c 2011-03-23 12:11:46.000000000 +0100 @@ -2827,6 +2827,21 @@ static int compare_candidates (const str * moved out of order with respect to their parent sections. */ if (strcmp (lsource->ext, rsource->ext)) { + const char **sp; + + /* If the user asked for an explicit section, sort exact + * matches first. + */ + if (section) { + if (STREQ (lsource->ext, section)) { + if (!STREQ (rsource->ext, section)) + return -1; + } else { + if (STREQ (rsource->ext, section)) + return 1; + } + } + /* Find out whether lsource->ext is ahead of rsource->ext in * section_list. */