Merge "Refactor fc_sort and add unit tests"