Sorting structs?

2014-01-29 Thread Boomerang

Hello everybody. I'm trying to learn D by solving simple
exercises.

The current exercise: read names and grades of students, then
print the names of students in descending order of their grades.

In C++, I would define a Student struct, overload the operators:
bool operator(const Student, const Student)
std::istream operator(std::istream, Student)

Then I'd store the Students in let's say a std::vector, sort it
in reverse, then print it accordingly.

But I don't know how to do things in D. I'm reading Cehreli's
book, so far I've only finished its first trinity (just before
struct).

I would appreciate it if you explained your approach and gave
source code illustrating it. Thanks!


Re: Sorting structs?

2014-01-29 Thread Boomerang
Also sorry for double posting but I'm confused how the sorting 
works when we only specify to be sorted by grade. I think in C++, 
disregarding other data members can lead to loss of data in 
things such as std::set.


Re: Sorting structs?

2014-01-29 Thread Boomerang

Thanks for the help so far.
My current code is here: http://dpaste.dzfl.pl/b9acff399649

Are there problems with my code, or do you have suggestions to 
improve it?