JPQL ORDER BY clause with parameter
If you want to use named queries here, you'd need two of them (named queries are static and you can't use ASC and DESC as parameter as pointed out by @Mark).
The "ASC" or "DESC" can't be a query parameter. You could use string concatenation instead.
query = "SELECT c FROM item ORDER BY c.name " + sortOrder;
You should validate that the contents of sortOrder
can only be ASC or DESC and does not come directly from the user.