dear I have this list
@@spelers = Speler.new(‘Jan Janssens’, ‘M’, 5, ‘SR’),Speler.new(‘Leen
Leniksen’, ‘V’, 7),
Speler.new(‘Piet Pieters’, ‘M’, 3), Speler.new(‘Els Elsenbocht’,
‘V’, 1, ‘J’),
Speler.new(‘Karel Carlsen’, ‘M’, 8), Speler.new(‘Mieke Mieters’,
‘V’, 9, ‘P’),
Speler.new(‘John Johanses’, ‘M’, 5, ‘J’), Speler.new(‘Veerle
Veldsen’, ‘V’, 3)
and I need to sort them into a top three for every mail and female in
this list
the M is for mail the V for female.
I have a def gender? geslacht
@geslacht = geslacht
end
I know you could solve it like the example below however I would like to
do it with an IF structure or with a bubble sort but not able to figure
this out
could someone help me out here and give me an example on how to solve
this
def self.top3 geslacht
per_geslacht(geslacht).sort_by { |x| x.score
}.to_a.slice(-3,3).reverse
end
when it’s an if structure
I should start somehow with
if speler.score1 > speler.score2
print speler.score1
else
print speler.score2
but after this I,m lost since I don’t know how to difference the first
person from the second
thanks for your help and feedback
Paul