[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch #3596] Sort directories before files in "ls"
From: |
Francesco Montorsi |
Subject: |
Re: [patch #3596] Sort directories before files in "ls" |
Date: |
Thu, 22 Dec 2005 09:41:23 +0100 |
User-agent: |
Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929) |
Alfred M. Szmidt wrote:
sure; the patch (int its old version - see Eric blake comments on
it) is attached to this mail.
I wanted to look at the updated one, sorry for not being clear.
sorry but before updating the patch I'd like to have a reply to my following
problem:
Eric Blake wrote:
>> + return 1; // b goes before a
>> +
>> + /* a and b are both files or both folders;
>> + will be sorted later using the user-selected sortkey */
>> + return 0;
>> +}
>> +
>> +int group_dirs_first()
>> +{
>> + int i, n=0;
>> + qsort (files, files_index, sizeof *files, cmp_directories);
>
>
>
> EVIL. You are calling qsort twice for every element (once to put
> directories first, then twice again on the subsets). This is twice as
> slow as just writing a proper sort function that does everything all in
> one comparison, so that you only call qsort once.
however if we want to make a single qsort call, then we'll need to declare a lot of new
functions which merge previous tests with the groupdir test:
static int groupdir_compare_name (V a, V b)
static int groupdir_compstr_name (V a, V b)
static int groupdir_rev_cmp_name (V a, V b)
static int groupdir_rev_str_name (V a, V b)
static int groupdir_compare_extension (V a, V b)
static int groupdir_compstr_extension (V a, V b)
static int groupdir_rev_cmp_extension (V a, V b)
static int groupdir_rev_str_extension (V a, V b)
...
is it right ?
Won't that clutter the source file ?
Thanks a lot,
Francesco
- Re: [patch #3596] Sort directories before files in "ls", (continued)
- Re: [patch #3596] Sort directories before files in "ls", Eric Blake, 2005/12/14
- Re: [patch #3596] Sort directories before files in "ls", Francesco Montorsi, 2005/12/15
- Re: [patch #3596] Sort directories before files in "ls", Francesco Montorsi, 2005/12/20
- Re: [patch #3596] Sort directories before files in "ls", Jim Meyering, 2005/12/21
- Re: [patch #3596] Sort directories before files in "ls", Francesco Montorsi, 2005/12/21
- Re: [patch #3596] Sort directories before files in "ls", Alfred M\. Szmidt, 2005/12/21
- Re: [patch #3596] Sort directories before files in "ls", Francesco Montorsi, 2005/12/21
- Re: [patch #3596] Sort directories before files in "ls", Alfred M\. Szmidt, 2005/12/21
- Re: [patch #3596] Sort directories before files in "ls", Francesco Montorsi, 2005/12/21
- Re: [patch #3596] Sort directories before files in "ls", Alfred M\. Szmidt, 2005/12/21
- Re: [patch #3596] Sort directories before files in "ls",
Francesco Montorsi <=
- Re: [patch #3596] Sort directories before files in "ls", Eric Blake, 2005/12/22
- Re: [patch #3596] Sort directories before files in "ls", Francesco Montorsi, 2005/12/27
- Use of bison, Eric Blake, 2005/12/29
- Re: Use of bison, Francesco Montorsi, 2005/12/29
- Re: Use of bison, Paul Eggert, 2005/12/29
- Re: [patch #3596] Sort directories before files in "ls", Eric Blake, 2005/12/29
- Re: [patch #3596] Sort directories before files in "ls", Francesco Montorsi, 2005/12/29
- Re: [patch #3596] Sort directories before files in "ls", Alfred M\. Szmidt, 2005/12/22
- [patch #3596] Sort directories before files in "ls", Francesco Montorsi, 2005/12/27