fixed sorting min max minor bug