code: def format_energy_results(energy):
      
      if not energy:
          return {}
      result = {}
      cpuenergy = Decimal(0)
      for pkg, domains in energy.items():
          for domain, value in domains.items():
              if domain == DOMAIN_PACKAGE:
                  cpuenergy += value
                  result['cpuenergy-pkg{}'.format(pkg)] = value
              else:
                  result['cpuenergy-pkg{}-{}'.format(pkg, domain)] = value
      result['cpuenergy'] = cpuenergy
      result = collections.OrderedDict(sorted(result.items()))
      return result
docs: Take the result of an energy measurement and return a flat dictionary that contains all values.