'Entropy discretization on a sorted C.
:param C: (N, K) array of class distributions.'

@classmethod
def _entropy_discretize_sorted(cls, C, force=False):

    (E, ES1, ES2) = cls._entropy_cuts_sorted(C)
    if (len(E) == 0):
        return []
    cut_index = (np.argmin(E) + 1)
    S1_c = np.sum(C[:cut_index], axis=0)
    S2_c = np.sum(C[cut_index:], axis=0)
    S_c = (S1_c + S2_c)
    ES = cls._entropy1(np.sum(C, axis=0))
    (ES1, ES2) = (ES1[(cut_index - 1)], ES2[(cut_index - 1)])
    Gain = (ES - E[(cut_index - 1)])
    k = float(np.sum((S_c > 0)))
    k1 = float(np.sum((S1_c > 0)))
    k2 = float(np.sum((S2_c > 0)))
    assert (k > 0)
    delta = (np.log2(((3 ** k) - 2)) - (((k * ES) - (k1 * ES1)) - (k2 * ES2)))
    N = float(np.sum(S_c))
    if (Gain > ((np.log2((N - 1)) / N) + (delta / N))):
        (left, right) = ([], [])
        if ((k1 > 1) and (cut_index > 1)):
            left = cls._entropy_discretize_sorted(C[:cut_index, :])
        if ((k2 > 1) and (cut_index < (len(C) - 1))):
            right = cls._entropy_discretize_sorted(C[cut_index:, :])
        return ((left + [cut_index]) + [(i + cut_index) for i in right])
    elif force:
        return [cut_index]
    else:
        return []
