How do I group resources by say MediaType?

It’s easy to group pages, e.g. .Pages.GroupBy "Dir" or .Pages.GroupBy "Section", but is it possible to do the same for .Resources? E.g. by MediaType so that I got one group for image/jpeg and another for image/png, or by .Dir, etc.

{{$pngImages := where (.Resources.ByType "image") "MediaType.SubType" "png"}}
{{range $pngImages}}
...
{{end}}