code: def port_list_compress(port_list):
      
  
      if not port_list or len(port_list) == 0:
          LOGGER.info("Invalid or empty port list.")
          return ''
  
      port_list = sorted(set(port_list))
      compressed_list = []
      for key, group in itertools.groupby(enumerate(port_list),
                                          lambda t: t[1] - t[0]):
          group = list(group)
          if group[0][1] == group[-1][1]:
              compressed_list.append(str(group[0][1]))
          else:
              compressed_list.append(str(group[0][1]) + '-' + str(group[-1][1]))
  
      return ','.join(compressed_list)
docs: Compress a port list and return a string.