# Sort with an inner object
# Here it will sort with "book_no"
# [
# {
# "key": "book-key-1",
# "book_no": 1,
# "name": "My Book Name 1"
# },
# {
# "key": "book-key-2",
# "book_no": 2,
# "name": "My Book Name 2"
# }
# ]
def sortOnNumber(e):
return e['book_no']
@app.get('/getBooks')
def getBooks():
res = next(booksDb.fetch())
res.sort(key=sortOnNumber)
if res:
return res
raise HTTPException(404,"Not found")