-   Linux - General (
-   -   Arranging Files In Alphabetical order (

swatward 12-11-2006 04:17 PM

Arranging Files In Alphabetical order
This seems like it'd be really simple, but how do i arrange files by alphabetical order from command line.

If i have
that should be

How do i Do this?
I'm just blanking out here.

zetabill 12-11-2006 04:20 PM

Normally ls gives it's output in alphabetical order by default. Are you using something else?

swatward 12-11-2006 04:24 PM

er sorry, yeah bad questions. I have an upload script that also lists the files a a certain order, but it's doing it in some random order.

Heres the code for the sorting part

PHP Code:

$filelist "";
while (
$file readdir($handle)) {
is_dir($file) && !is_link($file)) {
$filelist .= "
<table border=1><tr><td bgcolor='white' width='100%'><a href='

$filelist .="";

matthewg42 12-11-2006 05:29 PM

Put the results of readdir in an array, and then call sort on it. You can then iterate over the array and test for directories and links (and discard them).

You can see an example here. It must be true - google told me.

swatward 12-11-2006 08:14 PM

aight cool, thanks.

All times are GMT -5. The time now is 03:46 PM.