In the following dictionary,can the elements be sorted according the last prefix in the key
opt_dict=(
{'option1':1,
'nonoption2':1,
'nonoption3':12,
'option4':6,
'nonoption5':5,
'option6':1,
'option7':1,
})
for key,val in opt_dict.items():
if "answer" in key: //match keys last prefix and print output
print "found option 1,4,6,7" //in ascending order
elif "nonanswer" in key: //match keys last prefix and print output
print "found option 2,3,5 " //in ascending order
Thanks..