Order by sum of digits

Write a function @sum_of_digits_sorted(f)@ that provided a list of non negative integers ff returns a list gg with the very same numbers in ff. Numbers in gg must appear in increasing sum of digits. For instance, if 5656 and 21312131 are numbers in ff, number 21312131 will appear before 5656 in gg because the sum of digits of 21312131 (sum is 7) is less the sum of digits of 5656 (sum is 11). Numbers of the same sum of digits must appear in the usual increasing order.

Sample session

Problem information

Author: ProAl

Generation: 2026-01-25T15:23:49.269Z

© Jutge.org, 2006–2026.
https://jutge.org