I want to sort order my REST results data with a lookup column's Id in my SharePoint list.

I tried using $orderby in my REST query, but got no luck.

can anyone of you help me out with this ?

below is the query I am using and in that "CourseTitle" is the field based on whose Id I want to order the result. Please note that I want to sort by Id only, Not by LookUp Title.

_spPageContextInfo.webAbsoluteUrl + "_api/web/lists/getbytitle('Training Evaluation')/items/?$select=Title,Id,CourseTitle/Id,CourseTitle/Title&$expand=CourseTitle&$orderby=CourseTitle"
  • 2
    I could replicate your issue. OrderBy always sorts lookup title, not id. You can try sorting it after you get all the items using Javascript.
    – Akhoy
    Jul 27, 2015 at 7:28

1 Answer 1


Try this:

_spPageContextInfo.webAbsoluteUrl + "_api/web/lists/getbytitle('Training Evaluation')/items/?$select=Title,Id,CourseTitle/Id,CourseTitle/Title&$expand=**CourseTitle/Id**&$orderby=**CourseTitle/Id**"

  • not working, it seems that orderby itself doesn't have any significance in my rest query Jul 27, 2015 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.