Sort the columns based on identifier, get the sum of the values and the number of rows counted
I have a text file with 8 columns. I want to sort columns 1 and 3 based on the number before the first “_” in the string. After filtering, the values in column 8 must be summed. Also, the output must include the number of rows counted.