def get_sort_map(lens_array):
    """sort input by length in descending order,
    return the sorted index and the mapping between old and new positions"""

    sorted_example_ids = sorted(list(range(len(lens_array))), key=lambda x: -lens_array[x])

    example_old2new_pos_map = [-1] * len(lens_array)
    for new_pos, old_pos in enumerate(sorted_example_ids):
        example_old2new_pos_map[old_pos] = new_pos

    return sorted_example_ids, example_old2new_pos_map