Hello,
I have a country hash map where the keys are the respective iso-3166 alpha-2 codes and values are the common names of the countries. When trying to iterate through the hashmap Hugo sorts by the keys. How do I sort by value on a map?
Example code:
---
au: Australia
ch: Switzerland
gb: United Kingdom
kr: South Korea
---
{{ range $id, $name := .Site.Data.countries }}
<a href="{{ $id }}">{{ $name }}</>
{{ end }}
Sometimes it’s easier to visualize the data as JSON (the jsonify function can help with this). Your data is currently a single object with four keys. It is not an array.