Results 1 to 3 of 3

Thread: [RESOLVED] Sorting array problem

  1. #1

    Thread Starter
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308

    Resolved [RESOLVED] Sorting array problem

    I have populated an array first column with filenames and second column with folder and filenames. I want to sort the array with respect to filename i.e. first column. I tried different array sorting functions but none gave me correct results.

    Here's my code.

    Code:
            while (($file = readdir($dh)) != false) {
                // print "filename: $file : filetype: " . filetype($dir . $file) . "\n";
                if(filetype($dir . $file)!='dir' and !in_array($file,$att))
                {
    				$filearray[$i][0] = $file;
    				$filearray[$i][1] = $dir.$file;
    				$i++;
    			}			
            }
    Thanks.

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Sorting array problem

    Have you looked atarray_multisort() might do just what you want. Check out the comments as well as there is loads of useful information that will help you, or could point you to a better solution.

  3. #3

    Thread Starter
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308

    Re: Sorting array problem

    I don't know why but none of the sort functions were working. Finally, I wrote my own sort function using selection sort and its working now.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width