I met a problem in sorting a file containing astudents fistnane, secondname and GPA.if I sort the file using first name or lastname their Gpa will be miss placed please help me.
the file is:
kalayu haile 3.5
fikadu adisu 3.99
eyob assefa 3.25
getaneh allesew 3.75
fraol gezahegn 3.00
jim broun 4.00
allonline
0
Newbie Poster
Recommended Answers
Jump to PostYou have to decide whether you want to sort the file by name or by GPA. If you want it sorted alphabetically then sort by last name (or second name) then first name. If you want it sorted by GPA then sort by gpa, last name and first name.
…
Jump to PostIf you store your new structs that AncientDragon suggested in a std::vector, you can then use sort() from STL <algorithm>
Dave
Jump to PostThreads merged
All 11 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
allonline
0
Newbie Poster
daviddoria
334
Posting Virtuoso
Featured Poster
allonline
0
Newbie Poster
daviddoria
334
Posting Virtuoso
Featured Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Radical Edward
301
Posting Pro
allonline
0
Newbie Poster
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
allonline
0
Newbie Poster
peter_budo
2,532
Code tags enforcer
Team Colleague
Featured Poster
jonsca
commented:
Thanks Peter!
+4
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.