diff --git a/extra/rosetta-code/top-rank/top-rank.factor b/extra/rosetta-code/top-rank/top-rank.factor index 49ac7ec62d..6f8bf95502 100644 --- a/extra/rosetta-code/top-rank/top-rank.factor +++ b/extra/rosetta-code/top-rank/top-rank.factor @@ -1,7 +1,7 @@ ! Copyright (c) 2012 Anonymous ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs fry io kernel math.parser sequences -sorting ; +sorting math.statistics ; IN: rosetta-code.top-rank ! http://rosettacode.org/wiki/Top_rank_per_group @@ -46,11 +46,8 @@ CONSTANT: employees { T{ employee f "Timothy Grove" "E16398" 29900 "D190" } } -: group-by ( seq quot -- hash ) - H{ } clone [ '[ dup @ _ push-at ] each ] keep ; inline - : prepare-departments ( seq -- departments ) - [ department>> ] group-by + [ department>> ] collect-by [ [ salary>> ] inv-sort-with ] assoc-map ; : first-n-each ( seq n quot -- )