Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This function removes the duplicates in @candidates & returns a hash of candidates (%candidates)
- # which contains candidates & their number of occurences in @candidates
- # This function take as argument the list of candidates (@candidates)
- sub clean_candidates {
- my ($this,@candidates) = @_;
- my %candidates = (); # my %candidates ( $candidate => $nbOcc );
- foreach my $candidate (@candidates){
- $candidates{$candidate} ++;
- }
- my %sorted_candidates = sort ({ $candidates{$a} <=> $candidates{$b} } %candidates);
- return %sorted_candidates;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement