@@ -93,7 +93,7 @@ for prize in prizes:
9393### 📚 Primary and secondary sorting
9494![ image] ( https://user-images.githubusercontent.com/51888893/204382060-571d2118-4469-4142-bd7f-f3005f853ffb.png )
9595
96- ## : gorilla What the sort?
96+ ## 🦍 What the sort?
9797> This block prints out the first five projections of a sorted query. What "sort" argument fills the blank?
9898``` py
9999docs = list (db.laureates.find(
@@ -108,3 +108,17 @@ for doc in docs[:5]:
108108 {'born': '1901-02-28', 'prizes': [{'year': '1954'}, {'year': '1962'}]}
109109 {'born': '1913-07-12', 'prizes': [{'year': '1955'}]}
110110 {'born': '1911-01-26', 'prizes': [{'year': '1955'}]}
111+ Possible Answers
112+ - [x] [ ("prizes.year", 1), ("born", -1)]
113+ - [ ] {"prizes.year": 1, "born": -1}
114+ - [ ] None
115+ - [ ] [ ("prizes.year", 1)]
116+ answer
117+ ``` py
118+ docs = list (db.laureates.find(
119+ {" born" : {" $gte" : " 1900" }, " prizes.year" : {" $gte" : " 1954" }},
120+ {" born" : 1 , " prizes.year" : 1 , " _id" : 0 },
121+ sort = [(" prizes.year" , 1 ), (" born" , - 1 )]))
122+ for doc in docs[:5 ]:
123+ print (doc)
124+ ```
0 commit comments