Move sorting into tabComplete