Sort list by func(parameter)

I have a list of members, each with a name param like so:

content/members/abe.md

name: Abe Lincoln

content/members/bush.md

name: George W. Bush

layouts/members/list.html

{{ range sort .Data.Pages.ByParam "name" }}
{{ .Params.Name }}
{{ end }}

I’d like to sort them in a list by last name, but I can’t (read: don’t want to) define a separate parameter for last name, so I was hoping I could do something simple such as split the name parameter, and take the last element. Something like this perhaps:

{{ range sort (last 1 (split (.Data.Pages.ByParam "name") " ")) }}

However, that doesn’t work and spits out the following error:

<.Params.name>: can't evaluate field Params in type string

The only workaround (other than defining an additional param) that I’ve found is to rename my files: content/members/lincoln.abe and content/members/bush.george.w, and also change to `{{ range .Data.Pages }}, but I’d like to avoid that if possible.

My questions:

  1. Is this type of sorting supported by Hugo’s template syntax?
  2. Is my workaround of re-naming files a reliable way of achieving my desired sort order?
  3. Is there any other way I can achieve this sort order without having to add additional parameters?

Thanks!

Drop the “sort” function call, which is superflous.

Dropped, and tested with and without prior to posting.