sort refact