Re: can i make this better?

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Sat, 7 Feb 2004 14:26:39 -0500, Greg Haberek
<g.haberek at comcast.net> wrote:

>
>
>I want to sort the results from dir() so that all the directories are first,
>then the files, in alphabetical order. I'm using custom_sort() and
>compare(), so far this is what I have:
>
I have not tested this at all, but off the top of my head something
like this should work:

function compare_dir(object x1, object x2)
integer x1d
    x1d=find('d', x1[D_ATTRIBUTES])!=0
   if x1d=find('d', x2[D_ATTRIBUTES])!=0 then
	return compare(lower(x1[D_NAME]), lower(x2[D_NAME]))
   end if
   if x1d then return -1 else return 1 end if
end function

Regards,
Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu