String sort problem


why is one testcase wrong?

@aditi2512201012019 I think you mess up with check_substring function and other code please add comments in function.
OR you can try again let me give you solution first find if there is any substring present if yes then compare length otherwise compare string normaly.
You can use find function for checking substring but it is always good practice to code with inbuilt function