Does it mean that we don't care about the index value [$2] ?
I mean : this $2 value is in fact not the value of the index itself : it is mapped to an internal increment** of the current A [i]element ?
(**) this internal increment would be the real one over which the for construct iterates.
when the value of $2 takes - for example - the value 5 and then 3
The array looks like this :
when $2=5
the M array is
M[1] = unknown
M[2] = unknown
M[3] = unknown
M[4] = unknown
M[5] = $7
M[6] = unknown
...
and when the
$2=3
the M array is
M[1] = unknown
M[2] = unknown
M[3] = $7
M[4] = unknown
M[5] = $7
M[6] = unknown
...
?
or does it build an array such as :
M[5]=$7
M[3]=$7
So that in a way or another, is has an internal mapping table or whatever, in which it hold the order in which the [n] has been entered, so it start by scanning M[5] before M[3] whereas 3<5 ...
???
So in short :
i takes the values of $2 in the for construct, but awk still manage a mapping with an internal index mapping or whatever, which helps it to keep the order in which the M[$2] value are entered (even if $2 does not have ordered values)
Is that correct ? or should i go to buy another brain ?
After line 1 M["AD0081010180947"] contains the value 1010180950
After line 2 M["AD0081010180947"] contains the value 1010180956
after line 3 M["AD0081010180947"] contains the value 1010181014
after line 4 M["AD0081010180947"] still contains the value 1010181014
after line 5 M["AD0081010180947"] contains the value 1010181014 and M["ED0061010180949"] contains the value 1010180956
etc.
Simpler if not as resource-sparing: sort all by columns 7 reverse (not unique) pipe sort unique column 2. The sort -u saves the first holder of a key value. If you want a sequential presentation on another column, that is a third sort.