getting table sorted