pattern & sort