from typing import List


def _IntRange(mask: str) -> List[int]:
  """Converts an integer mask into a sorted list of integers.

  _IntRange('0,1,5-7') == [0, 1, 5, 6, 7]

  Args:
    mask: String integer mask as from MPI pinning list

  Returns:
    Sorted list of integers from the mask
  """
  ints = []
  for raw in mask.split(','):
    parts = raw.split('-')
    start = int(parts[0])
    end = start if len(parts) == 1 else int(parts[1])
    ints.extend(list(range(start, end + 1)))
  return sorted(ints)