Author Topic: SB_EXT  (Read 1188 times)

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Tireless poster
  • *****
  • Posts: 1899
    • View Profile
SB_EXT
« on: February 02, 2010, 10:21:34 PM »
Another aberration concerns the sorting by extension of files, at present the names of directories are considered as names of classic files with an extension, while they should be considered names without extension.

you have to unselect 'folder before' in the menu

solution:
Quote
 case sortby of
    SB_SIZE: result:=compare_(f1.size, f2.size);
    SB_TIME: result:=-compare_(f1.mtime, f2.mtime);
    SB_DL: result:=-compare_(f1.DLcount, f2.DLcount);
    SB_EXT: begin
            if not (f1.isfolder or f2.isfolder) then result:=compareExt(f1.name, f2.name)             // two files or links  --> sort by ext
            else if (f1.isfolder and f2.isfolder) then result:=ansiCompareText(f1.name, f2.name)   // two folders  --> sort by name
            else if f2.isfolder then result:=1    // sort as without extension
            else result:=-1;
            end;

    SB_COMMENT: result:=ansiCompareText(f1.comment, f2.comment);
    else result:=0;
    end;
« Last Edit: February 03, 2010, 12:03:51 AM by Mars »

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12953
    • View Profile
Re: SB_EXT
« Reply #1 on: February 09, 2010, 11:59:14 PM »
you are right.
but i opted for a different solution

Code: [Select]
  result:=0;
  case sortby of
    SB_SIZE: result:=compare_(f1.size, f2.size);
    SB_TIME: result:=-compare_(f1.mtime, f2.mtime);
    SB_DL: result:=-compare_(f1.DLcount, f2.DLcount);
    SB_EXT:
      if not f1.isFolder() and not f2.isFolder() then
        result:=compareExt(f1.name, f2.name);
    SB_COMMENT: result:=ansiCompareText(f1.comment, f2.comment);
    end;

because compareText is already done below when result is 0, and we should not mess with folders-before because it's already handled few lines above.