'Get the loose keys in order of decreasing frequency'

def _loose_keys_ordered(self):

    loose_counts = sorted(self.counts_loose.items(), key=(lambda x: x[1]), reverse=True)
    keys = np.array(loose_counts)[:, 0]
    counts = np.array(loose_counts)[:, 1]
    order = np.argsort(counts)[::(-1)].astype('int32')
    (keys, counts) = (keys[order], counts[order])
    specials = np.sort(self.specials.values())
    keys = np.concatenate((specials, keys))
    empty = np.zeros(len(specials), dtype='int32')
    counts = np.concatenate((empty, counts))
    n_keys = keys.shape[0]
    assert (counts.min() >= 0)
    return (keys, counts, n_keys)
