Fixed data conversion routines (correct sorting for Cox models)