Hello All, I am having a bit of trouble developing a proper sort that I will eventually be turning into a macro in which data is sorted in order within its own sub-group and then those sub-groups are sorted by the lowest value in the subgroup in descending (A-->Z) order. The data is then outputted to as per the original data (i.e the output isn't a subgroup, it is the original data that has been simply sorted).
Here is an example of what I am talking about utilizing playing cards:
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 439"]
<tbody>[TR]
[TD]Playing Card[/TD]
[TD]Associated Number[/TD]
[TD][/TD]
[TD]Card Suit[/TD]
[TD]Asociated Letter[/TD]
[TD]Associated Sort Number[/TD]
[/TR]
[TR]
[TD]Ace[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[TD]Hearts[/TD]
[TD]H[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Two[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[TD]Diamonds[/TD]
[TD]D[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]Three[/TD]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD]Spades[/TD]
[TD]S[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD]Four[/TD]
[TD="align: right"]4[/TD]
[TD][/TD]
[TD]Clubs[/TD]
[TD]C[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]Five[/TD]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Six[/TD]
[TD="align: right"]6[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Seven[/TD]
[TD="align: right"]7[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Eight[/TD]
[TD="align: right"]8[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Nine[/TD]
[TD="align: right"]9[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Ten[/TD]
[TD="align: right"]10[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jack[/TD]
[TD="align: right"]11[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Queen[/TD]
[TD="align: right"]12[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]King[/TD]
[TD="align: right"]13[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD][TABLE="width: 308"]
<tbody>[TR]
[TD]Sets of Suits[/TD]
[TD]Drawn Order[/TD]
[TD]Desired Suit Order[/TD]
[TD]Desired Overall Order[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]D2[/TD]
[TD][/TD]
[TD]S1[/TD]
[/TR]
[TR]
[TD]Hearts[/TD]
[TD]S7[/TD]
[TD]Hearts[/TD]
[TD]S4[/TD]
[/TR]
[TR]
[TD]H3[/TD]
[TD]C8[/TD]
[TD]H2[/TD]
[TD]S6[/TD]
[/TR]
[TR]
[TD]H5[/TD]
[TD]H2[/TD]
[TD]H3[/TD]
[TD]S7[/TD]
[/TR]
[TR]
[TD]H2[/TD]
[TD]D13[/TD]
[TD]H5[/TD]
[TD]S10[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]H5[/TD]
[TD][/TD]
[TD]H2[/TD]
[/TR]
[TR]
[TD]Diamonds[/TD]
[TD]H2[/TD]
[TD]Diamonds[/TD]
[TD]H3[/TD]
[/TR]
[TR]
[TD]D13[/TD]
[TD]S4[/TD]
[TD]D2[/TD]
[TD]H5[/TD]
[/TR]
[TR]
[TD]D2[/TD]
[TD]S1[/TD]
[TD]D8[/TD]
[TD]D2[/TD]
[/TR]
[TR]
[TD]D8[/TD]
[TD]S10[/TD]
[TD]D9[/TD]
[TD]D8[/TD]
[/TR]
[TR]
[TD]D9[/TD]
[TD]D9[/TD]
[TD]D13[/TD]
[TD]D9[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]D8[/TD]
[TD][/TD]
[TD]D13[/TD]
[/TR]
[TR]
[TD]Spades[/TD]
[TD]S6[/TD]
[TD]Spades[/TD]
[TD]C8[/TD]
[/TR]
[TR]
[TD]S1[/TD]
[TD][/TD]
[TD]S1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]S7[/TD]
[TD][/TD]
[TD]S4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]S10[/TD]
[TD][/TD]
[TD]S6[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]S4[/TD]
[TD][/TD]
[TD]S7[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]S6[/TD]
[TD][/TD]
[TD]S10[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Clubs[/TD]
[TD][/TD]
[TD]Clubs[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C8[/TD]
[TD][/TD]
[TD]C8[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
In this example the "Desired Suit Order" would be the sorting done into and within sub-groups and the "Desired Overall Order" is the desired results.
As can be seen the number of items in a group are dynamic. I would also like the number of sub-groups to be dynamic as well if, per this example, a 5th, 6th, etc. suit was added.
Any help / ideas are appreciated.
Thanks,
_____
Here is an example of what I am talking about utilizing playing cards:
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 439"]
<tbody>[TR]
[TD]Playing Card[/TD]
[TD]Associated Number[/TD]
[TD][/TD]
[TD]Card Suit[/TD]
[TD]Asociated Letter[/TD]
[TD]Associated Sort Number[/TD]
[/TR]
[TR]
[TD]Ace[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[TD]Hearts[/TD]
[TD]H[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Two[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[TD]Diamonds[/TD]
[TD]D[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]Three[/TD]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD]Spades[/TD]
[TD]S[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD]Four[/TD]
[TD="align: right"]4[/TD]
[TD][/TD]
[TD]Clubs[/TD]
[TD]C[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]Five[/TD]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Six[/TD]
[TD="align: right"]6[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Seven[/TD]
[TD="align: right"]7[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Eight[/TD]
[TD="align: right"]8[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Nine[/TD]
[TD="align: right"]9[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Ten[/TD]
[TD="align: right"]10[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jack[/TD]
[TD="align: right"]11[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Queen[/TD]
[TD="align: right"]12[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]King[/TD]
[TD="align: right"]13[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD][TABLE="width: 308"]
<tbody>[TR]
[TD]Sets of Suits[/TD]
[TD]Drawn Order[/TD]
[TD]Desired Suit Order[/TD]
[TD]Desired Overall Order[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]D2[/TD]
[TD][/TD]
[TD]S1[/TD]
[/TR]
[TR]
[TD]Hearts[/TD]
[TD]S7[/TD]
[TD]Hearts[/TD]
[TD]S4[/TD]
[/TR]
[TR]
[TD]H3[/TD]
[TD]C8[/TD]
[TD]H2[/TD]
[TD]S6[/TD]
[/TR]
[TR]
[TD]H5[/TD]
[TD]H2[/TD]
[TD]H3[/TD]
[TD]S7[/TD]
[/TR]
[TR]
[TD]H2[/TD]
[TD]D13[/TD]
[TD]H5[/TD]
[TD]S10[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]H5[/TD]
[TD][/TD]
[TD]H2[/TD]
[/TR]
[TR]
[TD]Diamonds[/TD]
[TD]H2[/TD]
[TD]Diamonds[/TD]
[TD]H3[/TD]
[/TR]
[TR]
[TD]D13[/TD]
[TD]S4[/TD]
[TD]D2[/TD]
[TD]H5[/TD]
[/TR]
[TR]
[TD]D2[/TD]
[TD]S1[/TD]
[TD]D8[/TD]
[TD]D2[/TD]
[/TR]
[TR]
[TD]D8[/TD]
[TD]S10[/TD]
[TD]D9[/TD]
[TD]D8[/TD]
[/TR]
[TR]
[TD]D9[/TD]
[TD]D9[/TD]
[TD]D13[/TD]
[TD]D9[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]D8[/TD]
[TD][/TD]
[TD]D13[/TD]
[/TR]
[TR]
[TD]Spades[/TD]
[TD]S6[/TD]
[TD]Spades[/TD]
[TD]C8[/TD]
[/TR]
[TR]
[TD]S1[/TD]
[TD][/TD]
[TD]S1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]S7[/TD]
[TD][/TD]
[TD]S4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]S10[/TD]
[TD][/TD]
[TD]S6[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]S4[/TD]
[TD][/TD]
[TD]S7[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]S6[/TD]
[TD][/TD]
[TD]S10[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Clubs[/TD]
[TD][/TD]
[TD]Clubs[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C8[/TD]
[TD][/TD]
[TD]C8[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
In this example the "Desired Suit Order" would be the sorting done into and within sub-groups and the "Desired Overall Order" is the desired results.
As can be seen the number of items in a group are dynamic. I would also like the number of sub-groups to be dynamic as well if, per this example, a 5th, 6th, etc. suit was added.
Any help / ideas are appreciated.
Thanks,
_____