hi guye please help how to sort a file like: with phone no.
name;class; phone no
mudit;5th;987654321
rohit;4th;98745321
sumit;7th;987654321
ankit;9th;984321
aaa;5th;987654321
bbb;5th;9874321
ccc;4th;98765421
ddd;8th;9876543
hi guye please help how to sort a file like: with phone no.
name;class; phone no
mudit;5th;987654321
rohit;4th;98745321
sumit;7th;987654321
ankit;9th;984321
aaa;5th;987654321
bbb;5th;9874321
ccc;4th;98765421
ddd;8th;9876543
One way you could do it would be to make a class that stores the details, something like:
class CPersonDetails
{
public :
CPersonDetails( const std::string& name, unsigned class, std::string number );
private :
std::string m_name;
unsigned m_class;
std::string m_phoneNumber;
};
You could then overload operator<
for this class and use std::sort
to order a std::vector
of CPersonDetails
objects.
Use the bubble sort algorithm
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.