File A
99 >ac [John 2] >ss[John 2] >juk[John 2]
70 >acb[Mona 3.1] >defa[Mona 3.1]
90 >ca[John 2]
100 >aa[John 2] >abc[John 2] >bca[John 2]
85 >cde[Mona 3.1]
81 >ghi[Rambo] >ghij [Rambo]
87 >def[Mona 3.1] >fgh[Mona 3.1] <ijk [Mona 3.1]
89 >fck[Rambo] >ghij[Rambo] >kill[Rambo] >aa[Rambo]
The given output shud be
100 >aa[John 2] >abc[John 2] >bca[John 2]
87 >def[Mona 3.1] >fgh[Mona 3.1] <ijk [Mona 3.1]
89 >fck[Rambo] >ghij[Rambo] >kill[Rambo] >aa[Rambo]
On the basis of text common within the square brackets , we can group accordingly and take one which have highest number in each group.
How can be done ?