This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Section 3.11.8 ends with the obsolete Note: Note: Since the order by clause in a FLWOR expression is the only facility provided by XQuery for specifying a value ordering, a FLWOR expression must be used in some queries where iteration would not otherwise be necessary. For example, a list of books with price less than 100 might be obtained by a simple path expression such as $books/book[price < 100]. But if these books are to be returned in alphabetic order by title, the query must be expressed as follows: for $b in $books/book[price < 100] order by $b/title return $b This could be replaced by a new Note: An alternative way of sorting is available from XQuery 3.1 using the fn:sort function. In previous versions of the language, a set of books might be sorted into alphabetic order by title using the FLWOR expression: for $b in $books/book[price < 100] order by $b/title return $b In XQuery 3.1 the same effect could be achieved using the expression $books/book => filter(function($book){$book/price < 100}) => sort(function($book){$book/title})
Fixed as suggested except for the second example I used: sort( $books/book[price < 100], function($book){$book/title} ) Because introducing fn:filter appears unnecessary and I found it slightly distracting when comparing the examples.