code: def group_envs(envlist):
      
      groups = {}
      for env in envlist:
          envpy, category = env.split('-')[0:2]
  
          if category == 'lint':
              category = 'unit'
  
          try:
              groups[envpy, category].append(env)
          except KeyError:
              groups[envpy, category] = [env]
  
      return sorted((envpy, category, envs) for (envpy, category), envs in groups.items())
docs: Group Tox environments for Travis CI builds
  
      Separate by Python version so that they can go in different Travis jobs:
  
      >>> group_envs('py37-int-snappy', 'py36-int')
      [('py36', 'int', ['py36-int']), ('py37', 'int', ['py37-int-snappy'])]
  
      Group unit tests and linting together:
  
      >>> group_envs(['py27-unit', 'py27-lint'])
      [('py27', 'unit', ['py27-unit', 'py27-lint'])]