 <p>I think that you should compare every character (A) of every name against the corresponding character (B) of all the other names, then, eventually, swap the two names if B and all characters preceding it are smaller than A and characters before. Right now that's my only idea but I can't translate it in code, I should think about it still some time...</p> <p>I tried to explain it as best as I could, anyway I'm sorry if it's a mess.. =)</p>