1
兩個價值在我的計劃,我想基於兩個值(得分和以前的排名)的球員我已經管理排序的球員進行排序..如何排序依據就在那裏得分基於在VBScript
我會喜歡重新排序,如果一個或多個玩傢俱有相同的得分,但具有最低的先前等級的玩家應該首先顯示。
dim mPlayer(30)
Class Player
dim score
dim name
dim lowestRank
End Class
dim sorted, i
dim tempPlayer
Set tempPlayer = New Player
sorted = False
Do Until sorted
sorted = True
For i = 0 To mNumPlayers - 2
If (mPlayer(i + 1).score > mPlayer(i).score) Then
' swap
sorted = False
Call CopytempPlayerData(tempPlayer, mPlayer(i))
Call CopytempPlayerData(mPlayer(i), mPlayer(i + 1))
Call CopytempPlayerData(mPlayer(i + 1), tempPlayer)
End If
Next
Loop
Set temptempPlayer = Nothing
lstPlayers.Clear()
For i = 0 To mPlayer - 1
lstPlayers.Items.add(mPlayer(i).name)
Next
嘗試通過'排序100000 * mPlayer(i).score±mPlayer(i).lowestRank'而不是裸mPlayer(i).score' where subst以最大'分數'值評價'100000'。然而,看看[排序算法](http://rosettacode.org/wiki/Category:Sorting_Algorithms)... – JosefZ
沒有最高分。我會嘗試mPlayer(i).score±mPlayer(i).lowestRank – Decoder94