Ubuntu – Should I alphabetically order the flags in a command as good practice

command line

I know that these two commands do the same thing:

ls -la
ls -al


but I'm wondering if there is any preference between them. Is it better practice to order them in a certain way?

It does not really matter* unless a command explicitly mentions. I have came across no reference that gave anything like a guideline how to put the options one after another. So I think for the sake of readability the options can be arranged alphabetically.

*There is a very very important cavaet that is if any option needs a filename or any other input right after it you need to put it accordingly.

For example, the -f option of grep takes a file as input to take the pattern to look for from the input file. You need to give the command as e.g.:

grep -cf input.txt file.txt


If you use it like:

grep -fc input.txt file.txt


it will fail as it will use c as a file name.