improve table sorting, partial fix bnc #885278