Observe the following example commands in bash:
jason@MacBook:~ mkdir temp
jason@MacBook:~ cd temp
jason@MacBook:~/temp touch file.txt
jason@MacBook:~/temp touch file1.txt
jason@MacBook:~/temp touch file2.txt
jason@MacBook:~/temp ls file*
file.txt file1.txt file2.txt
jason@MacBook:~/temp touch file0.txt
jason@MacBook:~/temp ls file*
file.txt file0.txt file1.txt file2.txt
jason@MacBook:~/temp touch fil.txt
jason@MacBook:~/temp ls fil*
fil.txt file.txt file0.txt file1.txt file2.txt
jason@MacBook:~/temp
As you can see from the output, all the file names are sorted in ascending lexicographic order.
I was wondering if this is a requirement by bash or whether it's implementation-specific, and it just so happened to work this way in my Mac's bash shell. The reason for which I'm asking is because if the file names are stored in a trie and it turns out that bash does indeed require that strings are printed in lexicographic order, a tiny amount of tweaking would be required in the code to traverse the trie correctly to print out the file names in this ascending order.