So lets say that I have a table like this..
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]TID[/TD]
[TD]Person[/TD]
[TD]Type[/TD]
[TD]Name[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Andy[/TD]
[TD]F[/TD]
[TD]Orange[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Andy[/TD]
[TD]M[/TD]
[TD]Beef[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Andy[/TD]
[TD]V[/TD]
[TD]Carrot[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Andy[/TD]
[TD]V[/TD]
[TD]Spinach[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Bobby[/TD]
[TD]M[/TD]
[TD]Ham[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Bobby[/TD]
[TD]F[/TD]
[TD]Apple[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Bobby[/TD]
[TD]V[/TD]
[TD]Carrot[/TD]
[/TR]
</tbody>[/TABLE]
I want to transpose it so that it will be sorted according to the Type, I want it to look like so
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Person[/TD]
[TD]F[/TD]
[TD]M[/TD]
[TD]V[/TD]
[/TR]
[TR]
[TD]Andy[/TD]
[TD]Orange[/TD]
[TD]Beef[/TD]
[TD]Carrot[/TD]
[/TR]
[TR]
[TD]Bobby[/TD]
[TD]Apple[/TD]
[TD]Ham[/TD]
[TD]Carrot[/TD]
[/TR]
</tbody>[/TABLE]
How can I manage to do this? Oh, and I'll also point some stuff in case you guys missed it:
1. The Types have no particular order, if you notice Andy's, the order is F M V V, but Bobby's is M F V.
2. Multiple instances of Type may occur, just like in Andy's case, notice the double V. But even so, I want it so that the only V that counts is the first one, thats why in the transposed table, the V is Carrot, because the Carrot occurred first (the Spinach is ignored).
I dont know if I ask too much, but even just the gist of the solution would be very helpful for me. The main point of my question is to ask how can I transpose such unsorted items, whilst paying attention to the 1st point. The 2nd point is important too, but I can wait or ask later if you guys dont feel like answering.
Thanks for reading, please share me your knowledge.
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]TID[/TD]
[TD]Person[/TD]
[TD]Type[/TD]
[TD]Name[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Andy[/TD]
[TD]F[/TD]
[TD]Orange[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Andy[/TD]
[TD]M[/TD]
[TD]Beef[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Andy[/TD]
[TD]V[/TD]
[TD]Carrot[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Andy[/TD]
[TD]V[/TD]
[TD]Spinach[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Bobby[/TD]
[TD]M[/TD]
[TD]Ham[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Bobby[/TD]
[TD]F[/TD]
[TD]Apple[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Bobby[/TD]
[TD]V[/TD]
[TD]Carrot[/TD]
[/TR]
</tbody>[/TABLE]
I want to transpose it so that it will be sorted according to the Type, I want it to look like so
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Person[/TD]
[TD]F[/TD]
[TD]M[/TD]
[TD]V[/TD]
[/TR]
[TR]
[TD]Andy[/TD]
[TD]Orange[/TD]
[TD]Beef[/TD]
[TD]Carrot[/TD]
[/TR]
[TR]
[TD]Bobby[/TD]
[TD]Apple[/TD]
[TD]Ham[/TD]
[TD]Carrot[/TD]
[/TR]
</tbody>[/TABLE]
How can I manage to do this? Oh, and I'll also point some stuff in case you guys missed it:
1. The Types have no particular order, if you notice Andy's, the order is F M V V, but Bobby's is M F V.
2. Multiple instances of Type may occur, just like in Andy's case, notice the double V. But even so, I want it so that the only V that counts is the first one, thats why in the transposed table, the V is Carrot, because the Carrot occurred first (the Spinach is ignored).
I dont know if I ask too much, but even just the gist of the solution would be very helpful for me. The main point of my question is to ask how can I transpose such unsorted items, whilst paying attention to the 1st point. The 2nd point is important too, but I can wait or ask later if you guys dont feel like answering.
Thanks for reading, please share me your knowledge.