Doubt in Question 4

can you please explain why the answer is bool and 1 not bool and 0?

@abhinavgoyal912
you can simply write your own comparator for sorting a array.
bool cmp(int a,int b){
return a<b;}

try to return a>b as well,
you will see that If we would like to see a before b in our final sorted ordering then cmp(a, b) should return true value.

1 Like

no but returning true will mean swap both of them right?and if we swap them then there order is destroyed

Nope returning true means the order will remain same.
A and then B

1 Like

ohhh sorry my bad. thanks

1 Like