Top rank per group: Difference between revisions
Content added Content deleted
m (→{{header|Picat}}: Added subsection) |
|||
Line 1,245: | Line 1,245: | ||
=={{header|Dyalect}}== |
=={{header|Dyalect}}== |
||
<lang dyalect>type Employee(name,id,salary,department) |
<lang dyalect>type Employee(name,id,salary,department) with Lookup |
||
func Employee.ToString() { |
func Employee.ToString() { |
||
Line 1,269: | Line 1,269: | ||
func topNSalaries(n) { |
func topNSalaries(n) { |
||
//We sort employees based on salary |
//We sort employees based on salary |
||
employees.Sort( |
employees.Sort((x,y) => y.salary - x.salary) |
||
let max = |
let max = |
||
if n > employees.Length() - 1 { |
if n > employees.Length() - 1 { |
||
Line 1,280: | Line 1,280: | ||
} |
} |
||
} |
} |
||
var seq = topNSalaries(5) |
var seq = topNSalaries(5) |
||