Repository: scipy/scipy

Issue:
DOC: in optimize.quadratic_assignment 2opt method, partial_match and partial_guess need to be sorted
### Issue with current documentation:

Documentation: https://scipy.github.io/devdocs/reference/optimize.qap-2opt.html#quadratic-assignment-method-2opt

For the optional arguments partial_match and partial_guess, it is unmentioned that they should be sorted in the first column. Functionality in lines https://github.com/scipy/scipy/blob/main/scipy/optimize/_qap.py#L692 and https://github.com/scipy/scipy/blob/main/scipy/optimize/_qap.py#L686 assumes so.

Alternatively, do that sorting internally before processing partial_match and/or partial_guess.

### Idea or request for content:

Doing sorting internally before processing partial_match and/or partial_guess seems like the best option, but documentation change could be sufficient.

### Additional context (e.g. screenshots, GIFs)

Output of a quick testing script. One observes that without sorting the partial_match input, the contents aren't actually preserved.

![quad_assign_not_working_2](https://github.com/scipy/scipy/assets/137289884/b89527f4-6115-468f-a8ee-109a70fa994f)



Discussion:
Hi @ErikVisseMartindale - would you be willing to submit a PR for the documentation? Here is our contributing guide: https://scipy.github.io/devdocs/dev/contributor/contributor_toc.html

Feel free to ping if you have questions! 😄 
Is this issue up for a contribution?
> Is this issue up for a contribution?

yes @yashasvimisra2798 go ahead!
I'm new to this but can i contribute to this?
yes @Suzaalx , there hasn't been a PR opened to address this yet!
I tried looking for the documentation but I couldn't find it inside doc/source/reference. i have been looking for the correct documentation for hours lmao.
The source for the documentation shown in https://scipy.github.io/devdocs/reference/optimize.qap-2opt.html#quadratic-assignment-method-2opt is the docstring here: https://github.com/scipy/scipy/blob/1925754c08e654efca1f56891a25735d4f08f0fd/scipy/optimize/_qap.py#L546

This is then extracted and autogenerated when the documentation pages are built.

Resolving patch:
diff --git a/scipy/optimize/_qap.py b/scipy/optimize/_qap.py
--- a/scipy/optimize/_qap.py
+++ b/scipy/optimize/_qap.py
@@ -598,6 +598,10 @@ def _quadratic_assignment_2opt(A, B, maximize=False, rng=None,
         ``partial_match[i, 0]`` of `A` is matched to node
         ``partial_match[i, 1]`` of `B`. The array has shape ``(m, 2)``,
         where ``m`` is not greater than the number of nodes, :math:`n`.
+
+        .. note::
+             `partial_match` must be sorted by the first column.
+
     partial_guess : 2-D array of integers, optional (default: None)
         A guess for the matching between the two matrices. Unlike
         `partial_match`, `partial_guess` does not fix the indices; they are
@@ -608,6 +612,9 @@ def _quadratic_assignment_2opt(A, B, maximize=False, rng=None,
         ``partial_guess[i, 1]`` of `B`. The array has shape ``(m, 2)``,
         where ``m`` is not greater than the number of nodes, :math:`n`.
 
+        .. note:: 
+                `partial_guess` must be sorted by the first column.
+
     Returns
     -------
     res : OptimizeResult


Test patch: