fix key sorting so it works differently for numbers or text