Fix sortfunction