def _get_time_series_params(ts_value_names, ts_values):
    """_get_time_series_params
    Converts data in ts_value_names and ts_values into the value_names
    and time_series_value_counts properties of the Facet API.

    ts_value_names is a dictionary mapping value names (such as True
    or '10-19') to numbers by which to sort the value names in the
    array final value_names array.

    ts_values contains a time-indexed array of pairs of arrays giving
    value names and counts, and is converted into the 2-dimensional
    array time_series_value_counts.

    Sample input:
    ts_value_names = {True: -5, False: -7}
    ts_values = [[[True, False], [4, 5]],
                 [[True, False], [1, 0]],
                 [[True, False], [0, 2]]]
    Sample output:
    value_names = [False, True]
    value_counts = [[5, 4],
                    [0, 1],
                    [2, 0]]
    """
    srt = sorted([(ts_value_names[i], i) for i in ts_value_names])
    value_names = [interval for value, interval in srt]
    for i in range(len(srt)):
        value, interval = srt[i]
        ts_value_names[interval] = i
    time_series_value_counts = []
    for entry in ts_values:
        cur_value_names = entry[0]
        cur_value_counts = entry[1]
        entry_array = [0 for name in value_names]
        for i in range(len(cur_value_names)):
            entry_array[ts_value_names[
                cur_value_names[i]]] = cur_value_counts[i]
        time_series_value_counts.append(entry_array)
    return value_names, time_series_value_counts