add the general sorting and add more handy function into tools