added ascending option to sorting