Chapter 4: Core Aggregation - Multidimensional Grouping - Facet Sorting Second Field

In regards with answer provided on the exam lab i do not think it’s quite right to with the sort provided in the assets, first field that is clear to get the top while second one is unrelated and may cause other important record to outside limit range.

1 Like

Another good observation @Igor_05290.
The second sort field (i.e. title) is not necessary. The correct sort produces the same result because of the dataset used.

Hi @Igor_05290,

That is a very good observation here. :star: I believe we are discussing the same lab: Lab - $facets. Let me know if I get it wrong.

You are right, the sort does not seem necessary to what has been asked in the question. But if not added, it might give different results if the dataset (different common movie) or the limit is changed.

First screenshot is without adding title to sort field and second is with one:

I hope it helps.


You’ve revealed quite a lot in your screenshot @kanikasingla :wink:

Thanks @007_jb, let me edit that! :slight_smile:

@kanikasingla @007_jb actually i think it’s better to put
First of all yes it’s the same lab as you’ve mentioned and that i’ve put in title
As for sorting i think i needs both combination in $facet in case for example there are more than 10 record with highest metacritic then best of the best will be to sort by rating

metacritic: DESC,
rating: DESC

Here is a sample data (let me know if i need to remove it).

var sampleMovie = [
{title: 'A', metacritic: 100, rating: 99},
{title: 'B', metacritic: 100, rating: 97},
{title: 'C', metacritic: 100, rating: 96},
{title: 'D', metacritic: 100, rating: 95},
{title: 'E', metacritic: 100, rating: 94},
{title: 'F', metacritic: 100, rating: 93},
{title: 'G', metacritic: 100, rating: 92},
{title: 'H', metacritic: 100, rating: 91},
{title: 'I', metacritic: 100, rating: 90},
{title: 'J', metacritic: 100, rating: 89},
{title: 'K', metacritic: 100, rating: 98}

From above we have we have 11 sample data, from the sorting provided in detailed explanation it will not include K when sorting by metacritic whilst in reality top 10 should include K but exclude J.

Am i making sense? Because in the question is best of the best in both fields metacritic and rating.

Hi @Igor_05290,

As I can check, you have successfully completed this lab. :clap:

If you still have any questions, please let me know.


it was more to bring to attention my observation and see if my point is right/wrong. I will complete this thread.

Hi @Igor_05290,

Please check your discourse inbox.

Let me know, if you have any questions.