4.16 Concatenate members with tied ranks

 

Rank records of the following score table by math score and concatenate names of students having same scores with the comma:

Name Math
Tom 85
John 92
Joan 86
Rocky 95
Ham 92
Kate 83
Rose 95
Nomy 78
Neil 92
Jack 86
Joe 98

SPL script:

A
1 =T(“score.xlsx”)
2 =A1.group(Math).(~.(Name).concat@c()).rvs().new(#:Rank,~:Name)

A2 Group the score table by math score (while sorting it by the grouping field by default), concatenate names in each group, and reverse the order of groups. The ordinal numbers of groups are the ranks we need.

Execution result:

Rank Name
1 Joe
2 Rocky,Rose
3 John,Ham,Neil
4 Joan,Jack
5 Tom
6 Kate
7 Nomy