- Issue #18096: Fix library order returned by python-config.
diff --git a/Misc/python-config.in b/Misc/python-config.in
index ca9857a..9ee0fdf 100644
--- a/Misc/python-config.in
+++ b/Misc/python-config.in
@@ -44,8 +44,9 @@
         print ' '.join(flags)
 
     elif opt in ('--libs', '--ldflags'):
-        libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
-        libs.append('-lpython'+pyver)
+        libs = ['-lpython' + pyver]
+        libs += getvar('LIBS').split()
+        libs += getvar('SYSLIBS').split()
         # add the prefix/lib/pythonX.Y/config dir, but only if there is no
         # shared library in prefix/lib/.
         if opt == '--ldflags':