Make the build funtion on host and call thrust sort from it.