Thank you, that works well.
I like grouped persons to be sorted by their firstname but somtimes I need them to be sorted by their lastname so this script works now (-1 designate the firstname sort order I’ve designed in preferences):
[Gramps SuperTool script file]
version=1
[title]
Individus-Sort_as of grouped persons
[category]
People
[initial_statements]
sort_by_fn = True # By firstname -> True; By lastname -> False
if sort_by_fn:
sort_order = -1
else:
sort_order = 0
[statements]
if "<<" in db.get_name_group_mapping(nameobjs[0].get_group_name()):
for n in nameobjs:
n.set_sort_as(sort_order)
[filter]
[expressions]
[scope]
selected
[unwind_lists]
False
[commit_changes]
True
[summary_only]
False
(be careful, commit changes is set)