API Design · Middle · Question 17 of 75
How should sort parameters usually look?
- 1Any SQL
ORDER BYexpression - ✓Correct answer: A list of allowed fields with direction, e.g.
?sort=-createdAt,name(minus for descending) - 3A numeric code per sort option
Explanation
Allow only indexed fields, and validate input to avoid injection into queries.