unixsortingdirectory

Unix ls -l implementation - sorting by name?


I'm implementing the mylsl.c (which is equivalent to "ls -l") method for Unix. Everything is set pretty much, except the contents of the current directory is being shown in a random order.

How could I sort the contents by filename?


Solution

  • The general solution to this problem is:

    The OS does not provide a way to list them in sorted order for you.