Add sorting by selection class

with testing unit