def clustermap_to_partition( cluster_map, doc_ids ):
	"""
	Convert a dictionary representing a clustering into a partition.
	"""
	cluster_names = list(cluster_map.keys())
	cluster_names.sort()
	# build document map
	partition = []
	doc_map = {}
	for i in range( len(doc_ids) ):
		partition.append( -1 )
		doc_map[ doc_ids[i] ] = i
	# now create partition
	for cluster_index in range( len(cluster_map) ):
		for doc_id in cluster_map[cluster_names[cluster_index]]:
			partition[doc_map[doc_id]] = cluster_index
	return partition