sort the matched items in python for more accuracy