Trying to create a .Pagenate, but struggling

I have a list of pages for a term, but I want them ordered by a piece of data that’s in an external file for each page. I have all that working, but then I need to get this back to a list of pages so that I can .Paginate.

 {{- $taxonomyName := .Title }}
  {{- $taxonomyShortName := .Title }}
  {{- $pages := where .Pages.ByWeight "Draft" "!=" true }}

  {{- $pagesWithData := slice }}
  {{- range $page := $pages }}
    {{- with .Resources.GetMatch "data.index.classifications.json" }}
      {{- $data := . | transform.Unmarshal }}
      {{- $dataItem := index $data $taxonomyName }}
      {{- if $dataItem }}
        <!-- Ensure the taxonomy exists in the data -->
        {{- $pagesWithData = $pagesWithData | append (dict "page" $page "score" ($dataItem.final_score | default 0)) }}
      {{- else }}
        {{- $pagesWithData = $pagesWithData | append (dict "page" $page "score" 0) }}
      {{- end }}
    {{- else }}
      {{- $pagesWithData = $pagesWithData | append (dict "page" $page "score" 0) }}
      <!-- Default when no data file -->
    {{- end }}
  {{- end }}
  {{- $sortedPagesWithData := sort $pagesWithData "score" "desc" }}
  {{- $sortedPages := slice }}
  {{- range $sortedPagesWithData }}
    {{- $sortedPages = $sortedPages | append .page.Page }}
  {{- end }}
  <pre>{{ printf "%#v" $sortedPages }}</pre>
  {{ range (.Paginate $sortedPages 7).Pages }}
    <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
  {{ end }}

This currently results in:

"C:\Users\MartinHinshelwoodNKD\source\repos\NKDAgility.com\site\layouts\categories\list.html:101:1": parse failed undefined variable "$score"  render: failed to render pages: render of "term" failed: "C:\Users\MartinHinshelwoodNKD\source\repos\NKDAgility.com\site\layouts\categories\list.html:102:20": execute of template failed at <.Paginate>: error calling Paginate: cannot convert type []map[string]interface {} to Pages  render: "C:\Users\MartinHinshelwoodNKD\source\repos\NKDAgility.com\site\layouts\categories\list.html:107:28": execute of template failed –  is nil; wrap it in if or with: {{ with  }}{{ .Pages }}{{ end }}  render: "C:\Users\MartinHinshelwoodNKD\source\repos\NKDAgility.com\site\layouts\categories\list.html:111:28": "C:\Users\MartinHinshelwoodNKD\source\repos\NKDAgility.com\site\layouts\categories\list.html:112:28": "C:\Users\MartinHinshelwoodNKD\source\repos\NKDAgility.com\site\layouts\categories\list.html:147:24": {{ with  }}{{ .HasPrev }}{{ end }}  render:"C:\Users\MartinHinshelwoodNKD\source\repos\NKDAgility.com\site\layouts\categories\list.html:107:37": execute of template failed – Paginate  7) is nil; wrap it in if or with: {{ with (.Paginate  7) }}{{ .Pages }}{{ end }}  render: "C:\Users\MartinHinshelwoodNKD\source\repos\NKDAgility.com\site\layouts\categories\list.html:108:37": "C:\Users\MartinHinshelwoodNKD\source\repos\NKDAgility.com\site\layouts\categories\list.html:107:35": execute of template failed at <collections>: can’t evaluate field Pages in type interface {} 

The debug output looks right as

page.Pages{(*hugolib.pageState)(0xc0143b9a40), (*hugolib.pageState)(0xc0138bb6c0), ...

Am I on the right track or completely wrong?

That variable isn’t referenced in the snippet you provided.