Implment ‘queue print by’ sorting