# How to Order Ints for a Custom Leaderboard

**URL:** <https://forums.unrealengine.com/t/how-to-order-ints-for-a-custom-leaderboard/1625022>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite\
**Created:** [January 18, 2024, 11:13pm UTC](https://forums.unrealengine.com/t/how-to-order-ints-for-a-custom-leaderboard/1625022 "2024-01-18T23:13:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![YouTube\_Giova](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@YouTube\_Giova](https://forums.unrealengine.com/u/YouTube_Giova)\
**Post date:** [January 18, 2024, 11:13pm UTC](https://forums.unrealengine.com/t/how-to-order-ints-for-a-custom-leaderboard/1625022/1 "2024-01-18T23:13:24Z")

</div>

Hello! So I’m Trying to make a custom leaderboard, but I don’t know how to order the scores from Highest to Lowest.

I’m using a map to store every player score.

```auto
var LBOrderMap : [player]int = map{}
                

```

So now I have a list of ints with the key being the player and I would want to know how to order those ints from highest to lowest!

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![bananna\_manuk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bananna\_manuk](https://forums.unrealengine.com/u/bananna_manuk)\
**Post date:** [January 20, 2024, 9:45pm UTC](https://forums.unrealengine.com/t/how-to-order-ints-for-a-custom-leaderboard/1625022/2 "2024-01-20T21:45:37Z")

</div>

[here’s the function you need](https://dev.epicgames.com/community/snippets/l0X/fortnite-array-sort-function)

---

<div class="post-metadata">

**Author:** ![NebojsaStrbac997](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NebojsaStrbac997](https://forums.unrealengine.com/u/NebojsaStrbac997)\
**Post date:** [January 23, 2024, 9:14am UTC](https://forums.unrealengine.com/t/how-to-order-ints-for-a-custom-leaderboard/1625022/3 "2024-01-23T09:14:13Z")

</div>

I am not sure if array sort would work on a map 🤔

---

<div class="post-metadata">

**Author:** ![bananna\_manuk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bananna\_manuk](https://forums.unrealengine.com/u/bananna_manuk)\
**Post date:** [January 23, 2024, 11:28pm UTC](https://forums.unrealengine.com/t/how-to-order-ints-for-a-custom-leaderboard/1625022/4 "2024-01-23T23:28:46Z")

</div>

here’s the loop we use to update our leaderboard

the player scores are ordered highest to lowest in the playerstandings array

```auto
CheckPlayerScores()<suspends>:void=
        loop:
            Players:=GetPlayspace().GetPlayers()
            for(i : int = 0..Players.Length):
                if(Player : agent = Players[i]):
                    if(Agent : agent =agent[Player]):
                            set CurrentScore = 0 
                            set CurrentScore += ScoreManagerDevice.GetCurrentScore(Agent)
                            if(CurrentScore >= PlayerScores[i]):
                                if(set PlayerScores[i] = CurrentScore){}
                                if(CurrentScore > HighScore):
                                    set HighScore = CurrentScore
            set PlayerStandings = Sort(PlayerScores, false, CompareInts)        
            UpdateLeaderBoard()            
            Sleep(0.5)

```
