Top rank per group: Difference between revisions

Content added Content deleted
m (→‎{{header|EchoLisp}}: deleted excess </lang>)
Line 1,247: Line 1,247:
<lang dyalect>type Employee(name,id,salary,department)
<lang dyalect>type Employee(name,id,salary,department)
func Employee.toString() {
func Employee.ToString() {
"$\(this::salary) (name: \(this::name), id: \(this::id), department: \(this::department)"
"$\(this.salary) (name: \(this.name), id: \(this.id), department: \(this.department)"
}
}
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(by: (x,y) => y::salary - x::salary)
employees.Sort(by: (x,y) => y.salary - x.salary)
let max =
let max =
if n > employees.len() - 1 {
if n > employees.Length() - 1 {
employees.len() - 1
employees.Length() - 1
} else {
} else {
n
n