Question: I want to write

```
struct Foo{
    MY_MACRO
};

```

and have that expand into

```
struct Foo{
    void bar(Foo&){}
};

```

How do I define MY\_MACRO? 

The only things I can come up with is the following:

```
#define MY_MARCO(X) void bar(X&){}
struct Foo{
    MY_MACRO(Foo)
};

```

This comes very close but is sub ideal, as I do not want to repeat the class name. 

Unfortunately the following does not compile:

```
struct Foo{
    void bar(decltype(*this)&){}
};

```

Answer: 
Annotate `Category` objects with the number of questions and then order by this number in descend order:

```
from django.db.models import Count

top_categories = Category.objects.annotate(q_count=Count('questions')) \
                                 .order_by('-q_count')[:7]

```

and you can look on the example in the doc [order-by](https://docs.djangoproject.com/en/2.0/topics/db/aggregation/#order-by), more examples for aggreagate [cheat-sheet](https://docs.djangoproject.com/en/2.0/topics/db/aggregation/#cheat-sheet)
In this case, they both do the same thing to sort the categories in the order of the number of questions they have in that field.

However, you will realize so many other uses `.annotate()` method. For example, you may want to sort the categories by the number of questions with a below and in descending order of the date.

You easily achieve this like so:

```
below_50 = Count('questions', filter=Q(marks__gte=50))
top_categories = Category.objects.annotate(below_50=below_50).order_by('-date')

```

In your situation, it's okay to just use `order_by` alone, but a more complex query of summing number of questions may require `.annotate()`