I would like to sort my base records by the last name of an author field. (Obviously in my case, the author field is not in last-name-first style). I understand that an official “last name” sort would be super complicated and impossible to get right, so I’m not asking for that.
I thought of a simple way to solve my problem by adding a formula field and sorting by that field. If there were formulas that did two simple things:
If author is a text property, then this returns the last word:
author.split(" ")[-1]
You can put that formula in a Bases property then sort on it.
But the method you’re asking for doesn’t account for two-word surnames, suffixes, multiple authors, and the like. A better practice would probably be to have a surname property in the note or, as you mentioned, type the surname first.
Hiya, Guapa, just want to point out that using index “1” works only on two-word names. So for, say, Zora Neale Hurston and Plato, you’d get “Neale” and null.
I know “-1” isn’t perfect either, so if you did see it—and you and I just subjectively prefer different, imperfect methods—then carry on! Commenting just in case you (or ChrisQ) hadn’t noticed the difference.
Thank you. I need to do some research to understand the difference between what 1 and -1 are doing. Only tried with name–surname pairs. I am sure your solution is the right way to go. Just need to work out why.
EDIT: [1] retrieves the second element; [-1] retrieves the last element. Brilliant.