Sorting alternating male and female

Can anyone suggest an algorithm to sort an array into althernating male and female? e.g.

Smith M

Smith F

Taylor M

Taylor F

The algorithm needs to disturb the list as little as possible so other criteria can also be used e.g. test scores. Also, it can't be exact because there is rarely exactly 50% of each.

[344 byte] By [Tave2a] at [2007-10-1 9:08:06]
# 1

Naively:Split data into 2 - male and female,

Sort both

Merge alternate entries from 2 arrays into 1.

That would mean the result of sorting A M

E M

F M

B F

C F

D F

would be

A M

B F

E M

C F

F M

D F

Pete

pm_kirkhama at 2007-7-10 1:32:15 > top of Java-index,Other Topics,Algorithms...
# 2
Pete,Thank you. Your idea would work.
Tave2a at 2007-7-10 1:32:15 > top of Java-index,Other Topics,Algorithms...