How can I sort a list of abbreviations?

Hey everyone, I want to include a list of abbreviations, and I want to sort them so that entries starting with numbers come first, followed by those starting with ‘A’ through ‘Z’. What would be the best way to get this in my typst document? Thanks!

The sorted function of an array is probably what you need here. It has more flexibility than shown here, but its default should be what you’re looking for.

#let abbreviations = ("73", "zs", "0b", "0a", "ab", "cd")
#abbreviations

#let abbrInOrder = abbreviations.sorted()
#abbrInOrder

The abbreviations are: #abbrInOrder.map(a => "'" + upper(a) + "'").join(", ", last: " and ").

image

Hi @FelixD, welcome and thank you for your question! I have changed your post’s title to bring it in line with the question guidelines and thus make it easier to understand from the title:

Good titles are questions you would ask your friend about Typst.

I also added the scripting tag, as it makes your question easier to find.

Thanks a lot! That’s exactly what I was looking for.