From the api docs:
retrieveXPathQuery(IContext context, java.lang.String xpathQuery, int amount, int offset, java.util.Map<java.lang.String,java.lang.String> sort)
Retrieves object list based on the given XPath query (synchronously).
See community commons for examples or snippet from ExcelReader
HashMap<String, String> sortMap = new HashMap<String, String>();
sortMap.put(Column.MemberNames.ColNumber.toString(), "ASC");
List<IMendixObject> columns = Core.retrieveXPathQuery(this.settings.getContext(), "//" + Column.getType() + "[" + Column.MemberNames.Column_Template + "=" + template.getId().toLong() + "]", Integer.MAX_VALUE, 0, sortMap);
Personally I'm a big fan of the XPath class that comes with Community Commons.
XPath<Question> xpat = XPath.create(context, Question.class);
xpat.addSortingDesc(Question.MemberNames.CreatedAt);
return xpat.limit(100).allMendixObjects();