How to consolidate values in one column from different rows into one?

Hi Guys,

Thank you all for helping me with my different queries and I continue to get better at scripting because of help from all of you!

I have a file that would look something like -

ID        SUB ID       VALUE
1           10             5
2           18             7
1           8              4
2           18             2
3           15             9
3           16             1
3           15             1
1           10             4

The output should be generated consolidated and sorted as following -

ID        SUB ID         VALUE (I dont care if headers are not generated too)
1         10                |4|5|
1           8                |4|
2         18                |2|7|
3         15                |1|9|
3         16                |1|

Grouping should be based on ID and SUB ID. SUB ID doesn't have to be in sorted order but would be nice to have. Can I achieve this through some AWK script?

As always, really appreciate your help! :b:

Something like that?

sort -n -k1 -k2 file | awk  '/^[0-9]/{a[$1 t $2]=(a[$1 t $2])?a[$1 t $2] $NF OFS:a[$1 t $2] OFS $NF OFS}END{for(i in a)print i t a}' t="\t" OFS="|"