import itertools
from typing import List


def itertools_combinations(string: str, n: int) -> List[str]:
    """
    >>> itertools_combinations('HACK', 2)
    ['A', 'C', 'H', 'K', 'AC', 'AH', 'AK', 'CH', 'CK', 'HK']
    >>> itertools_combinations('ABCD', 3) #doctest: +NORMALIZE_WHITESPACE
    ['A', 'B', 'C', 'D', 'AB', 'AC', 'AD', 'BC',
     'BD', 'CD', 'ABC', 'ABD', 'ACD', 'BCD']
    """
    rang = range(1, n+1)
    return sorted((''.join(tup) for i in rang
                   for tup in itertools.combinations(sorted(string), i)),
                  key=lambda x: (len(x), x))