diff --git a/Doc/conf.py b/Doc/conf.py
index 35e0b3eaeafe94..8eb2dd8cb63325 100644
--- a/Doc/conf.py
+++ b/Doc/conf.py
@@ -575,3 +575,8 @@
'',
'',
)
+
+# Options to adjust search results sorting
+# ----------------------------------------
+
+html_search_scorer = "tools/static/search_scorer.js"
diff --git a/Doc/tools/static/search_scorer.js b/Doc/tools/static/search_scorer.js
new file mode 100644
index 00000000000000..03cd6274079ffd
--- /dev/null
+++ b/Doc/tools/static/search_scorer.js
@@ -0,0 +1,32 @@
+var Scorer = {
+ score: function (result) {
+ let [docname, title, anchor, descr, score, filename] = result;
+
+ // boost the score of built-in functions and types
+ const builtinPages = ["library/stdtypes", "library/functions"];
+ if (builtinPages.includes(docname)) {
+ score += 7;
+ }
+
+ return score;
+ },
+
+ // Additive scores depending on the priority of the object
+ // Priority is set by object domains
+ // (see https://www.sphinx-doc.org/en/master/extdev/domainapi.html)
+ objPrio: {
+ 0: 15,
+ 1: 5,
+ 2: -5,
+ },
+ objPrioDefault: 0,
+
+ objNameMatch: 11, // score if object's name exactly matches search query
+ objPartialMatch: 6, // score if object's name contains search query
+
+ title: 15, // score if title exactly matches search query
+ partialTitle: 7, // score if title contains search query
+
+ term: 5, // score if a term exactly matches search query
+ partialTerm: 2, // score if a term contains search query
+};
diff --git a/Misc/NEWS.d/next/Documentation/2025-08-31-02-28-21.gh-issue-138277.kkORph.rst b/Misc/NEWS.d/next/Documentation/2025-08-31-02-28-21.gh-issue-138277.kkORph.rst
new file mode 100644
index 00000000000000..198d1de3121c5b
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2025-08-31-02-28-21.gh-issue-138277.kkORph.rst
@@ -0,0 +1,2 @@
+Rearranged documentation search results to emphasize built-in types and
+functions. Patch by Adam Hartz.