adds sorting functionality. solves #50