Page 1 of 1
sort Filename (Extension)
Posted: Sat Apr 15, 2023 5:01 pm
by Jimmy
hi,
i do "sort" Result of Directory() but it is not correct with Extension
Code: Select all | Expand
CASE nCol = LV_NAME
IF ::SortOrder = LVS_SORTASCENDING
ASORT( aDirOut, nStartAt + 1,, { | x, y | ( UPPER( x[ LV_NAME ] ), UPPER( y[ LV_NAME ] ), .T. ) } )
CASE nCol = LV_EXT
IF ::SortOrder = LVS_SORTASCENDING
ASORT( aDirOut, nStartAt + 1,, { | x, y | ( x[ LV_EXT ] + UPPER( x[ LV_NAME ] ) ) < ( y[ LV_EXT ] + UPPER( y[ LV_NAME ] ) ) } )
as you can "see" CDX is between C
how to change sort

Re: sort Filename (Extension)
Posted: Sat Apr 15, 2023 5:39 pm
by Natter
For example so:
Code: Select all | Expand
dim:=directoty("*.*")
ASORT( dim, ,, { | xx,y y | ( padl(UPPER(cFileExt(xx[1] )),5) < padl(UPPER( cFileExt(yy[1] ) ),5) } )
Or you can compare CRC file extensions
Re: sort Filename (Extension)
Posted: Sat Apr 15, 2023 6:03 pm
by Jimmy
hi,
thx for Answer
now CDX is behind BAT and before DBF
what i like to have is
*.C
*.CDX
*.CH
Re: sort Filename (Extension)
Posted: Sat Apr 15, 2023 6:19 pm
by Jimmy
hi,
i have use Idea of PAD but use PADR()

now it display like i want, thx
Re: sort Filename (Extension)
Posted: Sun Apr 16, 2023 12:47 pm
by nageswaragunupudi
PADR is not at all necessary.
Can try:
Code: Select all | Expand
? ASort( { "CDX", "c", "Cpp", "cH" },,,;
{ |x,y| LOWER( X ) < LOWER( y ) } )
For case insensitive
comparisons, we recommend using
Incidentally, this function Data Type safe also.
The above function can be written as:
Code: Select all | Expand
? ASort( { "CDX", "c", "Cpp", "cH" },,,;
{ |x,y| FW_Stricmp( x, y ) < 0 } )
Re: sort Filename (Extension)
Posted: Sun Apr 16, 2023 12:53 pm
by nageswaragunupudi
And wherever possible, it may be easier to leave the sorting business to xbrowse itself and xbrowse does a good job.
Code: Select all | Expand
local aDir := DIRECTORY( "c:\fwh\samples\*.*" )
SET DATE FORMAT TO "dd.mm.yyyy"
SET TIME FORMAT TO "hh:mm:ss"
AEval( aDir, { |a| a[ 3 ] := FW_AddTime( a[ 3 ], a[ 4 ] ), ;
AIns( a, 2, cFileExt( a[ 1 ] ) ), ASize( a, 4 ) } )
XBROWSER aDir AUTOSORT SETUP ( ;
oBrw:cHeaders := { "NAME", "EXT", "SIZE", "DATE" }, ;
oBrw:AutoFit(), ;
oBrw:SetDarkTheme() )

Re: sort Filename (Extension)
Posted: Mon Apr 17, 2023 6:16 am
by Jimmy
hi,
nageswaragunupudi wrote:And wherever possible, it may be easier to leave the sorting business to xbrowse itself and xbrowse does a good job.
thx for help
i´m sure it work under Fivewin but i use also HMG or Xbase++
so i always search Solution which i can use for all xBase-Dialect