Fix implementation for sorting tables in EI