You could use a regular expression to match numeric sequences. The number of matches would be the count of continuous number sequences.
A collections.Counter
would be a convenient way to get the frequencies of each match.
from collections import Counter
import re
raw_text = "blah123 hello9832 then32233 123"
matches = re.findall(r"\d+", raw_text)
print(f"found {len(matches)} number sequences")
counter = Counter(matches)
print(counter)
Output
found 4 number sequences
Counter({'123': 2, '9832': 1, '32233': 1})
To sort the results by frequency and break ties using the lexicographic ordering of the numeric sequences:
sorted_by_freq = sorted(counter.items(), key=lambda item: (-item[1], item[0]))
print(sorted_by_freq)
Output
[('123', 2), ('32233', 1), ('9832', 1)]