make table sorting work. bit hacky to keep the "header" row in place (reinserted after sort)