How to sort range output by weight

There are couple of discussions of that, but I could not understand. Is it possible to post a working sample of sorting range output? The range by default is sorted alphabetically, but I want to sort it by assigning weights. The output I want to sort are sizes in this order: “XS” - “S” - “M” - “L” - “XL” - “XXL”

What is a good syntax to assign weights? Should it be done in config.toml taxonomies or in _index.md file?

In a product description front matter I have a tag

sizes : ["S","M","XL"]

Here is the code that outputs the range of sizes and the amount of items per size:

 <ul class="list-unstyled">
   {{- range $name, $items := .Site.Taxonomies.sizes }}
   <li>
     <a class="cat-item d-lg-flex justify-content-between text-dark"
       href="{{ `sizes/` | relLangURL }}{{ $name | urlize | lower }}">{{ $name | title | upper }}<span>{{len $items}}</span></a>
   </li>
   {{- end }}
 </ul>

Thanks in advance!