Sort before trimming table, doh.