I have the following list<br clear="all"><br>List=[( &#39;G1&#39;, &#39;CFS&#39;, &#39;FCL&#39;, &#39;R1&#39; ),(&#39;G3&#39;, &#39;LOOSEFREIGHT&#39;, &#39;MIXEDLCL&#39;, &#39;R9&#39;), (&#39;G4&#39;, &#39;CFS&#39;, &#39;FCL&#39;, &#39;R10&#39; ), (&#39;G2&#39;,  &#39;LOOSEFREIGHT&#39;, &#39;LCL&#39;, &#39;R4&#39; ),  (&#39;G1&#39;, &#39;CFS&#39;, &#39;FCL&#39;, &#39;R2&#39; ), (&#39;G2&#39;, &#39;LOOSEFREIGHT&#39;, &#39;LCL&#39;, &#39;R5&#39;)  ]<br>
<br><br>now I want to group this elements of List  first by index [1] that is (CFS and LOOSEFREIGHT ) together and for those elements which are grouped together for  LOOSEFREIGHT, i want to further divide them into different groups based on index[2] that is (LCL or MIXEDLCL)<br>
<br><br>So essentially i want them grouped into different lists and my solution should be  of the form <br><br>New_List=[ [ ( &#39;G1&#39;, &#39;CFS&#39;, &#39;FCL&#39;, &#39;R1&#39; ), (&#39;G1&#39;, &#39;CFS&#39;, 
&#39;FCL&#39;, &#39;R2&#39; ), (&#39;G4&#39;, &#39;CFS&#39;, &#39;FCL&#39;, &#39;R10&#39; ) ], [ (&#39;G2&#39;,  &#39;LOOSEFREIGHT&#39;, 
&#39;LCL&#39;, &#39;R4&#39; ), (&#39;G2&#39;, &#39;LOOSEFREIGHT&#39;, &#39;LCL&#39;, &#39;R5&#39; )], [ (&#39;G3&#39;, 
&#39;LOOSEFREIGHT&#39;, &#39;MIXEDLCL&#39;, &#39;R9&#39;)] ]<br><br>How do I do it?<br><br>I managed to do divide them into different lists based on index [1] however I was not able to further divide them  based on index [2]<br>
<br>Any help is appreciated<br><br><br>