string sorting

i need a code which will be sorted by last name of the string??supoose if user enter 3 names like
1.rahul hossan
2.rahul amin
3.rahul rahman

for this the output will be
1.rahul amin
2.rahul hossan
3.rahul rahman
Please note, that this is not a homework site.
We won't do your homework for you.
The purpose of homework is that you learn by doing.
However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.


We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.

Edit: http://lmgtfy.com/?q=string+sorting+c%2B%2B
Last edited on
hope this helps.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//
#include <iostream>
#include <vector>
using namespace std;

int main (){
	
	using pss = pair<string, string>;
	vector<pss> vec;	
	vec.push_back(pss("first_name", "last_name"));
	
	cout << vec[0].first << " " << vec[0].second;
	
return 0;
}
Topic archived. No new replies allowed.