Sorting by `.Page.Weight` on `.Site.Taxonomies`

I’m attempting to list the categories used for a given section using the following snippet:

{{ range sort (where .Site.Taxonomies.category ".Page.Section" .Section).Alphabetical "Page.Weight" "asc" }}
...
{{ end }}

However, since not all of my categories have a weight param assigned, the weight is <nil> which sorts above weight = 1. Is there a way around this?

My workaround is to use DESC and invert the assigned weights.

Given this structure:

content
└── post/
    ├── _index.md
    ├── post-1.md  (weight = 2)
    ├── post-2.md  (weight = 1)
    └── post-3.md  (weight is not assigned)

The sequence when sorted by weight (ascending) will be:

Post 2
Post 1
Post 3

If you want pages without weights to appear first on the list:

content/post/_index.md

+++
title = 'Posts'
date = 2022-08-05T11:07:22-07:00
draft = false
[cascade]
  weight = -1000
+++

Those sorting rules don’t seem to apply here, though, as categories with no assigned weight already rank at the top. I suppose I could still cascade a weight to solve this, but I’m just wondering if it’s expected that nil would sort above 1 in my specific use case.

I would need to see your project repository to understand what is happening here.