Extract and sort all numbers that appear after ', I am currently learning Python and I wrote the following code.
The code searches the string for all digits that appear after ',, sorts them and joins them into a string.
I have a strong feeling that it can be shortened...
Can anyone suggest how?

s = "'bhhd',12 'kjubk',2 'bjki',98 'khjbjj',4"
res = re.findall(r"(',)(\d+)", s)
all = []
for r in res:
   all.append(r[1])

print(",".join(sorted(all, key=int)))
re.findall() behaves differently depending on whether the regex contains capturing parentheses.  If it doesn't contain capturing parentheses, then it just returns the matching text as a flat list.

So, how can you avoid capturing?  Just rewrite your regex to use a positive lookbehind assertion.

s = "'bhhd',12 'kjubk',2 'bjki',98 'khjbjj',4"
all = re.findall(r"(?&lt;=',)\d+", s)
print(",".join(sorted(all, key=int)))