def convert(results):
    """Converts the results to include metadata for navigation.

    Args:
        results: A dictionary mapping from hit_id to hit data.

    Returns:
        A dictionary containing:
            - hits: All hits ordered by workers.
            - workers: Mapping from worker_id to indices into hits.
    """
    # Organize all the data by worker id.
    worker_map = {}
    for hit_id, hit in results.items():
        for assignment in hit:
            worker_id = assignment['worker_id']
            if worker_id not in worker_map:
                worker_map[worker_id] = []
            worker_map[worker_id].append(assignment)

    # Create the hits and worker index mapping structures.
    hits = []
    worker_indices = {}
    worker_ids = []
    for worker_id, assignments in worker_map.items():
        worker_indices[worker_id] = range(
                len(hits), len(hits) + len(assignments))
        hits.extend(assignments)
        worker_ids.append(worker_id)
    output = {'hits': hits,
              'workers': worker_indices,
              'worker_ids': worker_ids}
    return output