String Sorting Lexographically

Greetings sir/mam
I think there’s a problem in sample output of this question as if we arrange these strings lexographically (apple, batman, bat) the output should be:

apple
bat
batman

whereas the sample output in this question is :

apple
batman
bat

please tell me if i’m wrong and please tell me what really lexographical order is.???

is it the methodology by the means of which the words are arranged in a dictionary?? and if it’s so then i think there’s is something wrong with the sample output…

Hi @harsh2707
The sample output is correct Please Go through the below two points your doubt will be cleared. If you still face any issue please let me know.

  1. In mathematics, the lexicographic or lexicographical order (also known as lexical order, dictionary order, alphabetical order or lexicographic(al) product) is a generalization of the way words are alphabetically ordered based on the alphabetical order of their component letters.
  2. If two words have varied in length, the usual lexicographical order pads the word with shorter length with blanks at the end until both words become the same in length, and then the words are compared

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.