Will this do what is supposed to do if, after ordering, the last class in `labels` is `most_label`? Since you have if, else if structure, then I am afraid that you won't get into this block. I can be perfectly wrong, though.