fix for keys sort function