Priority based clearsnippets

Implement priority-based clearsnippets and add corresponding test cases.