added sorting to qurey results