Special kind of array sorting

Hello.

I need some help on writing a function that will sort this array:

var newArray:Array = [<game title="Game Two" date="5.05.2007"><pics /><videos /></game>, <game title="Game One" date="5.06.2007><pics /><videos /></game>]

By the ‘title’ attribute, or the ‘date’ attribute.

I know that I can use Array.sort() for this, but it will only work with the first attribute.

Please help.