working quickSelect + final sort