Bird
0
0

Given the API request /products?sort=-rating, what will be the order of the returned products?

medium📝 Predict Output Q13 of 15
Rest API - Query Parameters and Filtering
Given the API request /products?sort=-rating, what will be the order of the returned products?
AProducts sorted by rating from highest to lowest.
BProducts sorted alphabetically by name.
CProducts sorted by rating from lowest to highest.
DProducts sorted by price from lowest to highest.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the sort parameter

    The parameter sort=-rating means sort by the field rating in descending order.
  2. Step 2: Determine the order of sorting

    Descending order means highest values first, so products with highest rating come first.
  3. Final Answer:

    Products sorted by rating from highest to lowest. -> Option A
  4. Quick Check:

    Minus prefix = descending order [OK]
Quick Trick: Minus means descending, so highest values first [OK]
Common Mistakes:
MISTAKES
  • Assuming minus means ascending
  • Confusing rating with price or name
  • Ignoring the minus sign

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes