--- Sukrit K Mehra <[EMAIL PROTECTED]> wrote:
> Hi listers,
> While doing this -->
>   @files = readdir(Favorites);
> i get an unsorted list in @files. What i desire is directories first
> and then files. Using sort function would sort by ascii value and
sort
> by_name and such won't work too. Please suggest a solution.

Sort allows a custom sorting function.
Try this:

  sub mySrt {
      ... some logic to produce the desired order,
          returning -1, 0, or 1
  }

  @files = sort mySrt readdir(Favorites);

Personally, though, I prefer splitting that sort of task into steps.

>   @files = readdir(Favorites);
    @dirs  = sort grep { -d }   @files;
    @plain = sort grep { ! -d } @files; # forgot to sort this 1st post
    @files = (@dirs,@plain);

Now @files is the directories in sorted order, then everything else in
sorted order. 

__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to