sorting done by distinct