sort by pattern