Search code examples
c#sharepointmosssharepoint-api

Sharepoint Lists.GetListItems sorting


I am making a call to Lists.GetListItems web method of sharepoint through my c# code. Is it possible to get sorted list from the sharepoint? Or do I have to sort it after retrieval in my c# code? I was not able to find any option in query or queryOptions.

Thanks.


Solution

  • See http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems.aspx

    GetListItems contains a parameter 'query'. If you pass an xml node in that query with something like:

    <OrderBy><FieldRef Name='fieldnametosort' /></OrderBy>
    

    You'll get a sorted list returned.