How can I put my taxonomy items into a fixed order?

I’ve read through the documentation and searched around and I can’t figure this out. I have a custom taxonomy that’s specified on every page, like so:

groups = ["Group A"]

Obviously there are other groups. It’s different depending on the page. In my template, I’m looping through the groups and their pages, like so:

{{ range $key, $value := .Site.Taxonomies.groups }}
    {{ range $value.Pages }}

This works okay. The problem is that the first loop puts the groups in an order that I don’t want. It seems like it’s just putting the groups in alphabetical order. I want to specify a fixed order somehow, like with weights.

Where and how can I do this?

Sort and Order Content

Thanks for the reply, but I don’t really see how that helps me. The former link talks about sorting things in ascending or descending order, and the latter link talks about ordering pages by weight, date, etc.

I’m already ordering my pages by weight and that’s great, but I want to do the same thing with these taxonomy items.

I’ll try to explain what I want again:

Some pages might have groups = ["Group A"]. Some pages might have groups = ["Group B"]. Some pages might have groups = ["Group C"].

So now we have “Group A”, “Group B”, and “Group C” defined as taxonomy items over several different pages.

When I look over the taxonomy items themselves (not the pages, the actual group names), using range over .Site.Taxonomies.groups, I want to go through the loop in a specific order. For example, I might want the range function to go over them in the order: Group B, Group C, Group A.

Does anybody know how to do this?

Have you solved this?
I have the same problem with the size taxonomy: S, M, L, XL and is coming out L, M, S, XL.

Use front matter to sort the terms. Mikhail answered this earlier. If you need assistance, read Requesting Help and post the code you need help modifying.