Char array sort

sol: https://ide.codingblocks.com/s/388286

prob:https://hack.codingblocks.com/app/contests/1975/966/problem

why are the elements not being sorted

What’s the issue in this question, is your answer coming wrong or you have an issue in understanding the problem?

I haven’t completed it yet but what I have done so far is not working the way it should be

Okay i will try to explain the question what it actually means
You are given three strings:
bat
apple
batman

Now you have to arrange it right? so you will see a is coming forward so yes

apple came

after that

bat is shorter then batman 
so it should have come before batman 
but here is the twist

When you get two strings such that one string can come under another string like bat came in batman. In this case we will print batman first and then bat.
So expected output is:

apple
batman
bat

can you please run my code and see why the output is not correct.

Use string instead of char, i did it


now all you have to do is handle this case

by making a comparator function

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.