[SD] Add sort function.