I' m stuck of last part of my code. I've to sort long string by sum of digit in it. That's part of my code which one I tried to solve it.
import re
@classmethod
def modified_user_checked_input(cls, user_checked_input: str) -> str:
return " ".join(sorted([(f"{a[0]}" + str((sum([int(i)for i in a if re.match(r"[1-9]", i)]))) + f"{a[-1]}") \
for a in user_checked_input.split(" ")])
User can entry that code which is (user_checked_input);
l99999999l a24124b c140w K125K C20A
The propoer output should be:
l72l c14w a13b K8K C2A
Does anyone know any simple algorythm for that one ?