Why this is showing error on leetcode?

problem link : https://leetcode.com/contest/weekly-contest-189/problems/rearrange-words-in-a-sentence/

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

what is exacly problem with comparator function???

and why just by changing (x.length() < y.length()) inside comparator is working fine???

hello @ssanjuchandra
i think by original order they mean -> lexicographical order.
thats why

this is working .
and
comparator with <= is not working

see this eg not in lexicographical : Input: text = “To be or not to be” Output: “To be or to be not”

this solution not working on other test case i gues test case 45??

can you submit my sol and check???

none of the comparator is working.

try this. store string and its index in pair .
then while sorting if length is same then compar their indices

refer this- > link

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.