I have three fields in dataset file.
field 1 acts as id
field 2 is used to compare the min
field 3 is boolean either 0 or 1.
I need to find the min value in field 2 but with respect to field 1. that is, consider below dataset.
dataset
1 0.432 0
1 0.12 1
1 0.298 0
2 0.056 0
2 0.06 1
3 0.982 0
I need to compare the values in field 2 for first 3 records and check if field 3 has value = 1 for the min value in field 2. if so, ++count.
Then find min again in field 2 but for records with field 1 = 2. that is, only record 4 and 5.and so on...
What would be the best way to go about with it? The file contains approx 2,000,000 records.
Is it possible to sort field 2 and then take one record for each different value of field1?