Fixed JS for table sort