awk group by multiple columns and print max value with non-primary key
<p>i'm new to this site and trying to learn awk. i'm trying to find the maximum value of field3, grouping by field1 and print all the fields with maximum value. Field 2 contains time, that means for each item1 there is 96 values of field2,field3 and field4</p>

<p>input file: (comma separated)</p>

<pre><code>item1,00:15,10,30
item2,00:45,20,45
item2,12:15,30,45
item1,00:30,20,56
item3,23:00,40,44
item1,12:45,50,55
item3,11:15,30,45
</code></pre>

<p>desired output:</p>

<pre><code>item1,12:45,50,55
item2,12:15,30,45
item3,11:15,30,45
</code></pre>

<p>what i tried so far:</p>

<pre><code>BEGIN{
FS=OFS=","}
{
if (a[$1]&lt;$3){
   a[$1]=$3}
}
END{
for (i in a ){
print i,a[i]
}
</code></pre>

<p>but this only prints </p>

<pre><code>item1,50
item2,30
item3,30
</code></pre>

<p>but i need to print the corresponding field2 and field4 with the max value as shown in the desired output. please help.</p>