I've been trying the expression node with x.sort(key = lambda o: o.name)
, but it gives no result.
How can I sort objects by name in this situation?
1 Answer
expression sorted(x, key = lambda o: o.name)
works well.
-
$\begingroup$ The explanation is because the
sort
method modifies the list in place and doesn't return a value, whilesorted
returns a new, sorted, list and doesn't change the input list. $\endgroup$– GorgiousJun 19, 2020 at 12:08