            if labels_topK.len() == 0 {
                labels_topK.push((label, freq));
            } else if labels_topK.last().unwrap().1 > freq || (labels_topK.last().unwrap().1 == freq && labels_topK.last().unwrap().0 < label) {
                if labels_topK.len() < K {
                    labels_topK.push((label, freq));
                }
            } else {
                for k in 0..(labels_topK.len()) {
                    if freq > labels_topK[k].1 || (freq == labels_topK[k].1 && label <= labels_topK[k].0) {
                        if labels_topK.len() < K {
                            labels_topK.push((0, 0.0f32));
                        }
                        for l in (k..(labels_topK.len()-1)).rev() {
                            labels_topK[l+1] = labels_topK[l];