Sort order for Sharepoint API “GET sites?search=*"

Ayase Morita 260 Reputation points
2025-02-05T01:26:28.12+00:00

https://learn.microsoft.com/en-us/answers/questions/2152627/sort-order-for-sharepoint-api-get-sites-search-*?comment=answer-1908331&page=1#comment-1894317

In the past, the above query showed that “GET sites?search=” does not support sorting, but “GET sites?search=&orderby=name” sorts alphabetically. The response we received was that “GET sites?search=*&orderby=name” sorts alphabetically.

I have an additional question: In the “GET sites?search=*&orderby=xxx” API, what is the sort order when “size” and “lastModifiedDateTime” are specified in the orderby query? I would like to know about the sort order when “size” and “lastModifiedDateTime” are specified in the orderby query.

Also, the following document states that the only property that can be sorted when searching a site is “createdDateTime”.

https://learn.microsoft.com/ja-jp/graph/api/site-search?view=graph-rest-1.0&tabs=http

Is it correct that both the “name” and “lastModifiedDateTime” properties are internally sorted, but only the “createdDateTime” property is able to refine the sorting function?

Microsoft 365 and Office | SharePoint | Development
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. AllenXu-MSFT 24,951 Reputation points Moderator
    2025-02-05T07:01:39.1766667+00:00

    Hi @Ayase Morita,

    I'm sorry that there are some mistakes in the previous case. After confirming with our team and test in our environment, the only property that works for sorting is createdDateTime. The GET sites?search=*&orderby=xxx API allows sorting by other properties.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Ayase Morita 260 Reputation points
    2025-02-05T08:05:38.5733333+00:00

    @AllenXu-MSFT

    Thanks for your response.

    GET sites?search=*&orderby=xxx

    If you specify a property in the xxx part of this API, it means that you can sort sites by the specified property.

    By the way, when I sort sites by name using GET sites?search=*&orderby=name, I can confirm that some sites are not sorted.

    I would like to know the cause of this issue.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.