There's no guarantee that after your second sort goes through that the order is preserved for the first elements. Under the covers, this uses mergeSort which could fuck around with the ordering.

I.e

sort 1 gives 'A-m B-m C-a D-a E-m F-a G-m H-a'
sort 2 gives 'H-a F-a D-a C-a A-m B-m E-m G-m' -- not the intended order at all.

What you should do is implement the "correct" compare method that checks both attributes at the same time, and returns the correct ordering.

Related: there should be a unit test for this method to validate that sorting works correctly with a few scenarios (i.e similar to what I put above, with a good mix).