def transform_hits(hits):
 packages = {}
 for hit in hits:
  name = hit['name']
  summary = hit['summary']
  version = hit['version']
  score = hit['_pypi_ordering']
  if (name not in packages.keys()):
   packages[name] = {'name': name, 'summary': summary, 'versions': [version], 'score': score}
  else:
   packages[name]['versions'].append(version)
   if (version == highest_version(packages[name]['versions'])):
    packages[name]['summary'] = summary
    packages[name]['score'] = score
 package_list = sorted(packages.values(), key=(lambda x: x['score']), reverse=True)
 return package_list

def transform_hits ( hits ) : packages = { } for hit in hits : name = hit [ 'name' ] summary = hit [ 'summary' ] version = hit [ 'version' ] score = hit [ '_pypi_ordering' ] if ( name not in packages . keys ( ) ) : packages [ name ] = { 'name' : name , 'summary' : summary , 'versions' : [ version ] , 'score' : score } else : packages [ name ] [ 'versions' ] . append ( version ) if ( version == highest_version ( packages [ name ] [ 'versions' ] ) ) : packages [ name ] [ 'summary' ] = summary packages [ name ] [ 'score' ] = score package_list = sorted ( packages . values ( ) , key = ( lambda x : x [ 'score' ] ) , reverse = True ) return package_list
the list from pypi is really a list of versions .