I have a pretty simple range, where i get key and value as variables. Problem now, is that instead of changing the order directly in the array, i would like to do it through the code.
Here is the template range code:
{{ range $bp, $width := .sizes }}
{{ $bp = (index $bps $bp) }}
{{ $print := false }}
{{ if $bp }}
{{ $print = (printf "(min-width: %vpx) %vpx" $bp $width) }}
{{ else }}
{{ $print = (printf "%vpx" $width) }}
{{ end }}
{{ $sizesSlice = $sizesSlice | append $print }}
{{ end }}
Here is .sizes:
"sizes": {
"0": 1920,
"1": 2560,
"2": 2048,
"3": 2200,
"4": 2800,
"5": 3840
}
So instead of appending to the slice with 0-5 it should instead be 5-0. Hope it makes sense.
The sort method i cant seem to use when i have they key and value as variables.