[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: SQR Verison



Thanks you for your suggestions and help.  I believe the max # of records is
about 500, so I will look into the bubble sort.







"Ray Ontko" <rayo@ONTKO.COM> on 03/31/2000 03:10:09 PM

Please respond to sqr-users@list.iex.net



 To:      SQR-USERS@list.iex.net

 cc:      (bcc: PARESH J. PATEL/EMPL/MD/Bell-Atl)



 Subject: Re: SQR Verison






Dan,

Yes, I've done a fair amount of research on sorting SQR arrays.
Somewhere, I've got bubble, insertion, selection, shell, and
quick sort routines, including improvements on the one published
in the SQR Users Guide.  Which algorithm you choose depends on
your exact circumstances, but for small arrays, bubble or insertion
sorts are fine, and shell or quick work well on large arrays (>>1000
records).  It all depends on how out-of-order the list is, and
how many fields there are in each record, and how much data
the fields contain.

The original inquirer, Paresh Patel, is interested in doing
sorts using multiple field keys.  This simply involves a
slightly more complex bit of comparison code.  Instead of
asking:

  if $key_left < $key

you ask:

  if $key_left_1 < $key_1 OR
     ( $key_left_1 = $key_1 AND $key_left_2 < $key_2 )

Ray

[Charset iso-8859-1 unsupported, filtering to ASCII...]
>         I'm not sure what Sam means when he says that you cannot sort an
> array as far as I know there are a variety of ways to sort an array. In the
> long run you would be better off spending some time writing a heap sort,
> merge sort, or selection sort. These algorithms have a worst case time
> complexity of nLogn whereas bubble sort has an every case time complexity of
> n^2 (n squared). However, a bubble sort is easy to write and I suspect that
> with SQR arrays it will much, much easier to write. I suspect that Ray Ontko
> and Tony DeLia (sorry if I spelled that wrong) may have some sorting
> procedures available on their sites. These guys are the masters and even if
> you can't use one of their algorithms you might get some ideas from them.
>
> Good Luck,
> Dan
>
>         -----Original Message-----
>         From:   Sam Spritzer [SMTP:SSpritzer@GW.CTG.COM]
>         Sent:   Friday, March 31, 2000 1:36 PM
>         To:     SQR-USERS@list.iex.net
>         Subject:        Re: SQR Verison
>
>         Generally speaking, you cannot sort an array but you can do a
> "bubble sort".  Check out www.sqrtools.com.  It really goes in depth about
> sorting arrays.
>         HTH,
>         Sam
>         >>> <paresh.j.patel@BELLATLANTIC.COM> 03/31 12:59 PM >>>
>         I am working on an SQR report in which I need to use an array.  Is
> there a way
>         to sort the array by multiple [character] fields?  Is so, can anyone
> provide me
>         an example?  Any help would be greatly appreciated.  Thank you.
>
>         SQR Version:  SQR/4.2.3/PC/Windows NT 4.0/ODBC Level1/Apr 22 1998
>
>         ===============================================================
>         "In the beginning, there was something which exploded...yet, they
> find nothing."
>
>         Sam Spritzer
>         sam.spritzer@ctg.com
>         www.ctg.com
>
>         Please see my personal web page at
>         home.adelphia.net/~spritzer/aboutme.html
>         for important information about contacting me.
>

----------------------------------------------------------------------
Ray Ontko   rayo@ontko.com   Phone 1.765.935.4283   Fax 1.765.962.9788
Ray Ontko & Co.   Software Consulting Services   http://www.ontko.com/