fix sorting function in View