Repository: ietf-tools/datatracker

Issue:
Document Search result: sort headers have wrong links
### Describe the issue

https://datatracker.ietf.org/doc/search?activedrafts=on&author=Bormann&by=author&name=&sort=date

is very useful to me.  Unfortunately, the sorting links in the table heading are all messed up, Document points to date, Date points to title, Status points to -date, IPR points to status, and AD/Shepherd points to IPR.

HTML excerpt below.


```
<tr>
                <th scope="col"></th>
                
                    
                        <th scope="col" data-sort="document" class="sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=date">
                                    Document
                                    
                                </a></th>
                    
                
                    
                
                    
                        <th scope="col" data-sort="date" class="sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=title">
                                    Date
                                    
                                </a></th>
                    
                
                    
                        <th scope="col" data-sort="status" class="sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=-date">
                                    Status
                                    
                                </a></th>
                    
                
                    
                        <th scope="col" data-sort="ipr" class="d-none d-sm-table-cell sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=status">
                                    IPR
                                    
                                </a></th>
                    
                
                    
                        <th scope="col" data-sort="ad" class="d-none d-sm-table-cell sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=ipr">
                                    AD/Shepherd
                                    
                                </a></th>
                    
                
            </tr>
<th scope="col"></th>
<th scope="col" data-sort="document" class="sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=date">
                                    Document
                                    
                                </a></th>
<a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=date">
                                    Document
                                    
                                </a>
<<pseudo>></<pseudo>>
<th scope="col" data-sort="document" class="sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=date">
                                    Document
                                    
                                </a></th>
<th scope="col" data-sort="date" class="sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=title">
                                    Date
                                    
                                </a></th>
<th scope="col" data-sort="status" class="sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=-date">
                                    Status
                                    
                                </a></th>
<th scope="col" data-sort="ipr" class="d-none d-sm-table-cell sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=status">
                                    IPR
                                    
                                </a></th>
<th scope="col" data-sort="ad" class="d-none d-sm-table-cell sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=ipr">
                                    AD/Shepherd
                                    
                                </a></th>
<tr>
                <th scope="col"></th>
                
                    
                        <th scope="col" data-sort="document" class="sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=date">
                                    Document
                                    
                                </a></th>
                    
                
                    
                
                    
                        <th scope="col" data-sort="date" class="sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=title">
                                    Date
                                    
                                </a></th>
                    
                
                    
                        <th scope="col" data-sort="status" class="sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=-date">
                                    Status
                                    
                                </a></th>
                    
                
                    
                        <th scope="col" data-sort="ipr" class="d-none d-sm-table-cell sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=status">
                                    IPR
                                    
                                </a></th>
                    
                
                    
                        <th scope="col" data-sort="ad" class="d-none d-sm-table-cell sort"><a href="?activedrafts=on&amp;author=Bormann&amp;by=author&amp;name=&amp;sort=ipr">
                                    AD/Shepherd
                                    
                                </a></th>
                    
                
            </tr>

``` 

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:

Resolving patch:
diff --git a/ietf/doc/utils_search.py b/ietf/doc/utils_search.py
--- a/ietf/doc/utils_search.py
+++ b/ietf/doc/utils_search.py
@@ -251,7 +251,6 @@ def num(i):
     if query and hasattr(query, "urlencode"):  # fed a Django QueryDict
         d = query.copy()
         for h in meta['headers']:
-            h["sort_url"] = "?" + d.urlencode()
             if h['key'] == sort_key:
                 h['sorted'] = True
                 if sort_reversed:
@@ -262,5 +261,6 @@ def num(i):
                     d["sort"] = "-" + h["key"]
             else:
                 d["sort"] = h["key"]
+            h["sort_url"] = "?" + d.urlencode()
 
     return (docs, meta)


Test patch: