
Want an if-else statement in your Python lambda? You can’t because it’s a statement. Instead, use the ternary operator:
sorted(items, key = lambda w: w if isinstance(w, str) else str(w))
In other words: If it’s a string, return the value. If not, return it as a string.
