Optimize order of pattern matches for export operations