Sorting using FindDocumentsByQueryWithPaging

0 votes

Hi, i'm trying to sort my storage with the key for my scores but it seems it's not working. I edit the scores on my json doc on the dashboard and run my app to check if the scores will sort but it didn't sort. Just to clarify my problem my goal is to sort the json docs by score. I'm using cocos2d-x

Here's my code:

  StorageService *storageService = App42API::BuildStorageService();

    Query *query = QueryBuilder::BuildQuery(APP42_KEY_USER_ID, userIds , APP42_OP_INLIST);

    map<string,string>otherMetaHeaders; // Use orderByDescending for Descending or orderByAscending for Ascending as key

    otherMetaHeaders["orderByDescending"] = “Score”;



    int max = 50;

    int offSet = 0;

    storageService->FindDocumentsByQueryWithPaging(“DBNAME”,”Debug_Scores”,query,max,offSet,app42callback(App42SyncUtils::onStorageRequestQuery, this));

asked Apr 30, 2015 in App42 Cloud API-BaaS by blackmagicstd (16 points)
Can you share the response string? It will be easy to debug if we know the response you are getting.
Hi, i think there's a bug when manually updating the data from the database. here's what I log during my test . What I tried to do first is setting the order by ascending and just run my app to see the response, at first it's just like normal. Second try, I try to edit the score from the database on Garlen from 18324 to 324 and as you can see the expected result is that the score of Garlen with 324 should be the first on response but the order didn't change at all.

1 Answer

+1 vote
Best answer


From the log you shared, it seems the value of Score is of type string. So as a number 324 less than 15833 but as a string "324" is greater than "15833".

That means "18324" & "324" both are higher in order if compared with "15833" as they are of type string.

Let me know if it helps.


answered Apr 30, 2015 by rajeev.etc (1,660 points)
selected Apr 30, 2015 by blackmagicstd
Thanks, didn't notice that.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on