Fixed EPR#398785 EPR#398788
Cleaned sort