# Sort descending numeric on the index field
func cmp(a, b) {
  return b.index <=> a.index;
}
begin {
  @records = [];  # Define as an array, else auto-create will make a map
}
@records[NR] = $*; # Accumulate
end {
  @records = sort(@records, cmp);
  for (record in @records) {
    emit record;
  }
}
