You don’t sort a single instance of your struct. You sort a container of structs. Whether that be an array, a vector, etc, that is up to you to decide.
You would read the file, populating the container with instances of your struct as needed, and then you would pass begin/end iterators for the range of container elements that you want to sort, providing a comparator that compares the fields of 2 given instances of the struct as needed.
For example:
struct details {
int emp_id;
int age;
char name[50]; // why not std::string?
};
std::vector<details> employees;
// populate employees as needed...
std::sort(employees.begin(), employees.end(),
[](const details &emp1, const details &emp2){
return std::strncmp(emp1.name, emp2.name, 50) < 0;
}
);