Multilingual data files

This is my current solution to get multilingual features similar to content files:

      {{ range $key, $e := $.Site.Data.team }}
        {{ if ne $.Site.LanguagePrefix "" }}
          {{ $.Scratch.Set "lang" (print "." (replace $.Site.LanguagePrefix "/" "")) }}
          {{ if in (printf $key) ($.Scratch.Get "lang") }}
            {{ with $e }}
              {{ partial "members.html" . }}
            {{ end }}
          {{ end }}
        {{ else }}
          {{ if or (not (in $key ".")) (in $key (print "." $.Site.Language.Lang)) }}
            {{ with $e }}
              {{ partial "members.html" . }}
            {{ end }}
          {{ end }}
        {{ end }}
      {{ end }}

data/team/$name.toml -> will be rendered as default for default language
data/team/$name.de.toml -> will be rendered on german pages
data/team/$name.en.toml -> will be rendered on english pages

For a default language of “en” both $name.toml and $name.en.toml will be rendered and basically merged.

Seems to work quite alright except, that I can’t seem to figure out how to sort with having variables set on range at the same time.
Sorting similar to this would be needed: {{ range sort $.Site.Data.team "joined" "asc" }}

Any suggestions on how to do sorting while retaining the variable assignment for keys and values?

This seems similar to this question: https://discuss.gohugo.io/t/index-on-sort/4279/2