how to sort array

Input file
000001<SORTID>64<IP>1<EMB01>5187 <EMB02>07/20-07/25<EMB03>SIMON
000002<SORTID>33<IP>1<EMB01>1341 <EMB02>07/20-07/25<EMB03>RYAN
000003<SORTID>125<IP>1<EMB01>1344<EMB02>07/20-07/25<EMB03>HOWARD

after sort
000002<SORTID>33<IP>1<EMB01>1341 <EMB02>07/20-07/25<EMB03>RYAN
000001<SORTID>64<IP>1<EMB01>5187 <EMB02>07/20-07/25<EMB03>SIMON
000003<SORTID>125<IP>1<EMB01>1344<EMB02>07/20-07/25<EMB03>HOWARD

Using SORTID to sort each line.
I don't know how to deal with above data is the best way.
My idea is getlin() line by line into array
and find() between <SORTID>and<IP> get sort id to sort.
after that i don't know how to switch array synchronouns..
There do you have any suggestion or good function can provider me ?

This is a little confusing to me. And there are many ways (well over 10) to sort an array. Look at this page and you may get some ideas: http://en.wikipedia.org/wiki/Sorting_algorithm
sort by what variable?
BY <SORTID> variable <IP>
THX
create a struct or class
1
2
3
4
5
6
7
8
struct T {
	int a;
	int b;
	int c;
	int d;
	string s1;
	string s2;
};


create objects (in array) for each line.
fill the values from data by file I/O
then, sort the array by any variable.
Last edited on
Topic archived. No new replies allowed.