# Leaderboard prev cursor

**URL:** <https://forum.heroiclabs.com/t/leaderboard-prev-cursor/5845>\
**Category:** Game Design\
**Tags:** sdk-unity, getting-started\
**Created:** [December 2, 2024, 1:09pm UTC](https://forum.heroiclabs.com/t/leaderboard-prev-cursor/5845 "2024-12-02T13:09:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![omerfarukkvk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/omerfarukkvk/32/2402_2.png) [@omerfarukkvk](https://forum.heroiclabs.com/u/omerfarukkvk)\
**Post date:** [December 2, 2024, 1:09pm UTC](https://forum.heroiclabs.com/t/leaderboard-prev-cursor/5845/1 "2024-12-02T13:09:19Z")

</div>

Hello,

I am currently dealing with the leaderboard and I noticed something about the prev cursor. While there is no problem with the record list that I first call with the prev cursor, when I call the 2nd call, the sorting is broken, what could be the reason?

here’s my code

```auto
private async void GetLeaderboard(string cursor)
        {
            try
            {
                var recordList = await Client.ListLeaderboardRecordsAsync(Session, "test", null, null, 5, cursor);
                List<IApiLeaderboardRecord> apiLeaderboardRecords = recordList.Records.ToList();
                apiLeaderboardRecords = apiLeaderboardRecords
                    .OrderByDescending(record => int.Parse(record.Score)) 
                    .ToList();

                var sortedRanks = apiLeaderboardRecords
                    .Select(record => int.Parse(record.Rank))
                    .OrderBy(rank => rank) 
                    .ToList();

                _nextCursor = recordList.NextCursor;
                _prevCursor = recordList.PrevCursor;
                
                string logMessage = "Fetched Records:\n";
                for (int i = 0; i < apiLeaderboardRecords.Count; i++)
                {
                    var record = apiLeaderboardRecords[i];
                    int newRank = sortedRanks[i];
                    logMessage += $"Score: {record.Score}, Rank: {newRank}\n";
                }
                Debug.Log(logMessage);
            }
            catch (System.Exception ex)
            {
                Debug.LogError($"Error fetching leaderboard: {ex.Message}");
            }
        }

```

lederboard outputs that I called twice using the next cursor and twice using the prev cursor:

```auto
--- log at the start of the game ---
Fetched Records:
Score: 266, Rank: 1
Score: 226, Rank: 2
Score: 206, Rank: 3
Score: 197, Rank: 4
Score: 179, Rank: 5

--- the first log I used the next cursor ---
Fetched Records:
Score: 170, Rank: 6
Score: 166, Rank: 7
Score: 158, Rank: 8
Score: 153, Rank: 9
Score: 151, Rank: 10

--- the second log I use the next cursor ---
Fetched Records:
Score: 150, Rank: 11
Score: 150, Rank: 12
Score: 149, Rank: 13
Score: 149, Rank: 14
Score: 147, Rank: 15

--- the first log I used the prev cursor ---
Fetched Records:
Score: 170, Rank: 6
Score: 166, Rank: 7
Score: 158, Rank: 8
Score: 153, Rank: 9
Score: 151, Rank: 10

--- the second log I use the prev cursor ---
Fetched Records:
Score: 266, Rank: 5
Score: 226, Rank: 6
Score: 206, Rank: 7
Score: 197, Rank: 8
Score: 179, Rank: 9

```

Am I missing something? Maybe you can see what I can’t see, thank you in advance for your help.

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [December 3, 2024, 11:03am UTC](https://forum.heroiclabs.com/t/leaderboard-prev-cursor/5845/2 "2024-12-03T11:03:50Z")

</div>

Hello @omerfarukkvk,

Are you running the latest Nakama version?

---

<div class="post-metadata">

**Author:** ![omerfarukkvk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/omerfarukkvk/32/2402_2.png) [@omerfarukkvk](https://forum.heroiclabs.com/u/omerfarukkvk)\
**Post date:** [December 3, 2024, 11:15am UTC](https://forum.heroiclabs.com/t/leaderboard-prev-cursor/5845/3 "2024-12-03T11:15:22Z")

</div>

Hello @sesposito,

Server version: 3.22.0+4a4c53d7

Nakama Unity version: 3.13.0

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [December 3, 2024, 11:31am UTC](https://forum.heroiclabs.com/t/leaderboard-prev-cursor/5845/4 "2024-12-03T11:31:11Z")

</div>

I couldn’t reproduce on `3.25.0` with a descending leaderboard with 81 records, I used the next\_cursor to fetch 3 pages of records with limit 5 and then from there used the prev\_cursor to get the previous pages (I used the REST API directly).

You shouldn’t need to order the records. If you keep encountering the issue, please provide a reproducible example to setup the leaderboard and listing to reproduce.

Best.
