Shape, pattern and sorting/matching