Bird
0
0

You want to get a list of products sorted by category ascending and then by price descending. Which sort parameter is correct?

hard📝 Application Q8 of 15
Rest API - Query Parameters and Filtering
You want to get a list of products sorted by category ascending and then by price descending. Which sort parameter is correct?
A/products?sort=category,-price
B/products?sort=-category,price
C/products?sort=price,-category
D/products?sort=category_price
Step-by-Step Solution
Solution:
  1. Step 1: Understand multi-field sorting syntax

    Multiple fields are separated by commas; prefix '-' means descending.
  2. Step 2: Match required order

    First sort by category ascending (no minus), then by price descending (with minus).
  3. Final Answer:

    /products?sort=category,-price -> Option A
  4. Quick Check:

    Comma separates fields; minus means descending [OK]
Quick Trick: Use commas to sort by multiple fields [OK]
Common Mistakes:
MISTAKES
  • Reversing order of fields
  • Misplacing minus sign
  • Using underscore instead of comma

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes