| 1 |
# Sort descending numeric on the index field |
| 2 |
func cmp(ak, av, bk, bv) { |
| 3 |
return bv.index <=> av.index |
| 4 |
} |
| 5 |
begin { |
| 6 |
@records = {}; # Define as a map |
| 7 |
} |
| 8 |
@records[NR] = $*; # Accumulate |
| 9 |
end { |
| 10 |
@records = sort(@records, cmp); |
| 11 |
for (_, record in @records) { |
| 12 |
emit record; |
| 13 |
} |
| 14 |
} |