× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 12/19/06, Jon Paris <Jon.Paris@xxxxxxxxxxxxxx> wrote:

Since multiplication is a pretty slow thing to do - wouldn't it be far
simpler - and _way_ more obvious - to code the sort this way?  This is how I
always do multi-key sorts, which is what this really is.

      select;
          when E1.Year < E2.Year;
               return -1;
          when E1.Year > E2.Year;
               return 1;
          other;
          select;
               when E1.Month < E2.Month;
                    return -1;
               when E1.Month > E2.Month;
                    return 1;
               other;
                    return 0;
          endsl;
      endsl;


Jon Paris
Partner400

www.Partner400.com


Which would get deeply nested for a bunch of keys. I have a generic
file comparison report, which needs to be able to compare 1 to n key
fields; I do it like:

<PRE><CODE>
p compKey         b
d                 pi            10i 0
/free
 $I = 0;
 DoU ($I = keyCnt Or memcmpstr <> 0);
    $I = $I + 1;
    memcmpstr = memcmp( @bfr1@($I)
                      : @bfr2@($I)
                      : @fldLnB($I)
                      );
 EndDo;

 Return memcmpstr;
/end-free
<CODE></PRE>
Where:

There are $I key fields

@bfr1@ is an array of pointers to the first character of the keyfields in the
first file to be compared.

@bfr2@ is an array of pointers to the first character of the keyfields in the
second file to be compared.

@fldLnB is an array containing the length of the keyfields.


This also has the added advantage of allowing me to determine how many
keys at run time, and not compile time.

www.brilligware.com/cp1030.html

Chris
--
chris@xxxxxxxxx           | You know you've achieved perfection in
www.pando.org             | design, not when you have nothing more
                         | to add, but when you have nothing more
                         | to take away. Antoine de Saint-Exupery

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.