Top rank per group: Difference between revisions

Content added Content deleted
imported>Arakov
imported>Arakov
Line 1,674: Line 1,674:
class Employee
class Employee
{
{
string Name : prop;
string Name : prop;
string ID : prop;
string ID : prop;
int Salary : prop;
int Salary : prop;
string Department : prop;
string Department : prop;
Line 1,684: Line 1,684:
.writePaddingRight(ID, 12)
.writePaddingRight(ID, 12)
.writePaddingRight(Salary.toPrintable(), 12)
.writePaddingRight(Salary.toPrintable(), 12)
.write:Department;
.write(Department);
}
}
Line 1,690: Line 1,690:
{
{
topNPerDepartment(n)
topNPerDepartment(n)
= self.groupBy:(x => x.Department ).selectBy:(x)
= self.groupBy::(x => x.Department ).selectBy::(x)
{
{
^ new {
^ new {
Line 1,696: Line 1,696:
Employees
Employees
= x.orderBy:(f,l => f.Salary > l.Salary ).top(n).summarize(new ArrayList());
= x.orderBy::(f,l => f.Salary > l.Salary ).top(n).summarize(new ArrayList());
}
}
};
};
Line 1,720: Line 1,720:
};
};
employees.topNPerDepartment:2.forEach:(info)
employees.topNPerDepartment(2).forEach::(info)
{
{
console.printLine("Department: ",info.Department);
console.printLine("Department: ",info.Department);
info.Employees.forEach:printingLn;
info.Employees.forEach(printingLn);
console.writeLine:"---------------------------------------------"
console.writeLine("---------------------------------------------")
};
};