sort with pattern