I need to sort an array that contains multiple objects. I need to first sort it by Rank, then by Last name.
Ex
Array[0].rank = 3 Array[0].name = Jones
Array[1].rank = 2 Array[1].name = Adams
Array[2].rank = 3 Array[2].name = Scott
Array[3].rank = 1 Array[3].name = Murphy
Array[4].rank = 3 Array[4].name = Daley
such that the output array is like this:
Array[0].rank = 1 Array[0].name = Murphy
Array[1].rank = 2 Array[1].name = Adams
Array[2].rank = 3 Array[2].name = Daley
Array[3].rank = 3 Array[3].name = Jones
Array[4].rank = 3 Array[4].name = Scott
I have attempted to create my own comparer class inheriting icompare but it doesnt seem to allow me to sort on 2 items at the same time. I can either sort on name or rank but if I sort on name before I sort on rank the items show up like this:
Array[0].rank = 1 Array[0].name = Murphy
Array[1].rank = 2 Array[1].name = Adams
Array[2].rank = 3 Array[2].name = Jones
Array[3].rank = 3 Array[3].name = Daley
Array[4].rank = 3 Array[4].name = Scott
Any help would be appreciated. thanks,
Ex
Array[0].rank = 3 Array[0].name = Jones
Array[1].rank = 2 Array[1].name = Adams
Array[2].rank = 3 Array[2].name = Scott
Array[3].rank = 1 Array[3].name = Murphy
Array[4].rank = 3 Array[4].name = Daley
such that the output array is like this:
Array[0].rank = 1 Array[0].name = Murphy
Array[1].rank = 2 Array[1].name = Adams
Array[2].rank = 3 Array[2].name = Daley
Array[3].rank = 3 Array[3].name = Jones
Array[4].rank = 3 Array[4].name = Scott
I have attempted to create my own comparer class inheriting icompare but it doesnt seem to allow me to sort on 2 items at the same time. I can either sort on name or rank but if I sort on name before I sort on rank the items show up like this:
Array[0].rank = 1 Array[0].name = Murphy
Array[1].rank = 2 Array[1].name = Adams
Array[2].rank = 3 Array[2].name = Jones
Array[3].rank = 3 Array[3].name = Daley
Array[4].rank = 3 Array[4].name = Scott
Any help would be appreciated. thanks,