add sort of table result. Need testing.