fixed a bug: y should be used in the lexigographical sorting