I followed an awesome online YouTube tutorial for using Power Automate to query SPO REST API to obtain search results and send the results back to Power Apps (Search File Content in Power Apps from SharePoint Document Libraries). Those results are then JSON Parsed and pushed into a Table to show up in a Gallery. The single-site-search result is sorted by Rank at the API side so no problems with the return. I then wanted to go further and create a universal search; search across two separate SharePoint sites and append the results into one mega result list creating one mega results gallery. However, since I'm appending search2 onto search1 the larger totalsearchresults is no longer sorted by Rank. search1 is sorted by Rank and then, separately, search2 is sorted by rank.
No big deal, sort when I'm in Power Apps? But I can't figure it out.
A single-search-result:
Flow run results is placed in a variable; varSearchResults. Flow responds to PowerApps as searchresults.
Gallery items is set to:
Table(ParseJSON(varSearchResults.searchresults))
Labels inside the Gallery:
LookUp(Table(ThisItem.Value.Cells),ThisRecords.Value.Key="Title").Value.Value
LookUp(Table(ThisItem.Value.Cells),ThisRecords.Value.Key="Rank").Value.Value
etc...
The actual search results in JSON look basically like:
{"Cells":[
{ "Key" : "Title",
"Value": "TitleOfThing"
},
{"Key":"Rank",
"Value":"900"
}
]
and so on. However, I can't figure out how to Sort or SortByColumns in the Gallery Items (aka Table(ParseJSON(varSearchResults.searchresults) to sort the entire large multi-site-search return by Rank. When I append search1 and search2 together and substring it out so it can Parse correctly in Power Apps, thereby creating a multi-site-search result, the second search might have an item of Rank 999 but it gets pushed to the bottom of the line in the Gallery when it may be the true first in line.
Hopefully that all makes sense and hopefully someone can be of help?